/* * Test shouldn't be run for a day, so add 10 days to child * time and check parent's time to be in the same day.
*/ #define DAY_IN_SEC (60*60*24) #define TEN_DAYS_IN_SEC (10*DAY_IN_SEC)
struct test_clock {
clockid_t id; char *name; /* * off_id is -1 if a clock has own offset, or it contains an index * which contains a right offset of this clock.
*/ int off_id;
time_t offset;
};
if (switch_ns(child_ns)) return pr_err("switch_ns(%d)", child_ns);
if (_gettime(clocks[clock_index].id, &cur_ts, raw_syscall)) return -1;
if (difftime(cur_ts.tv_sec, child_ts_new.tv_sec) < precision) {
ksft_test_result_fail( "Child's %s (%s) time has not changed: %lu -> %lu [%lu]\n",
clocks[clock_index].name, entry, parent_ts_old.tv_sec,
child_ts_new.tv_sec, cur_ts.tv_sec); return -1;
}
if (switch_ns(parent_ns)) return pr_err("switch_ns(%d)", parent_ns);
if (_gettime(clocks[clock_index].id, &cur_ts, raw_syscall)) return -1;
if (difftime(cur_ts.tv_sec, parent_ts_old.tv_sec) > DAY_IN_SEC) {
ksft_test_result_fail( "Parent's %s (%s) time has changed: %lu -> %lu [%lu]\n",
clocks[clock_index].name, entry, parent_ts_old.tv_sec,
child_ts_new.tv_sec, cur_ts.tv_sec); /* Let's play nice and put it closer to original */
clock_settime(clocks[clock_index].id, &cur_ts); return -1;
}
ksft_test_result_pass("Passed for %s (%s)\n",
clocks[clock_index].name, entry); return 0;
}
int main(int argc, char *argv[])
{ unsignedint i;
time_t offset; int ret = 0;
ksft_print_header();
nscheck();
check_supported_timers();
ksft_set_plan(ARRAY_SIZE(clocks) * 2);
if (init_namespaces()) return 1;
/* Offsets have to be set before tasks enter the namespace. */ for (i = 0; i < ARRAY_SIZE(clocks); i++) { if (clocks[i].off_id != -1) continue;
offset = TEN_DAYS_IN_SEC + i * 1000;
clocks[i].offset = offset; if (_settime(clocks[i].id, offset)) return 1;
}
for (i = 0; i < ARRAY_SIZE(clocks); i++) { if (clocks[i].off_id != -1)
offset = clocks[clocks[i].off_id].offset; else
offset = clocks[i].offset;
ret |= test_gettime(i, true, offset);
ret |= test_gettime(i, false, offset);
}
if (ret)
ksft_exit_fail();
ksft_exit_pass(); return !!ret;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.