Commit fa89ca44 authored by Song Chen's avatar Song Chen Committed by Jan Kiszka

y2038: testsuite/smokey/y2038: testcase for adjtime64

add test case for clock_adjtime64 in testsuite
Signed-off-by: default avatarSong Chen <chensong_2000@189.cn>
[Florian: Fix test error handling, style fixes, fix failing test]
Signed-off-by: default avatarFlorian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent a5f37f69
......@@ -28,6 +28,39 @@ struct xn_timespec64 {
int64_t tv_nsec;
};
struct xn_timex_timeval {
int64_t tv_sec;
int64_t tv_usec;
};
struct xn_timex64 {
int32_t modes; /* mode selector */
/* pad */
int64_t offset; /* time offset (usec) */
int64_t freq; /* frequency offset (scaled ppm) */
int64_t maxerror; /* maximum error (usec) */
int64_t esterror; /* estimated error (usec) */
int32_t status; /* clock command/status */
/* pad */
int64_t constant; /* pll time constant */
int64_t precision; /* clock precision (usec) (read only) */
int64_t tolerance; /* clock frequency tolerance (ppm) (read only) */
struct xn_timex_timeval time; /* (read only, except for ADJ_SETOFFSET) */
int64_t tick; /* (modified) usecs between clock ticks */
int64_t ppsfreq; /* pps frequency (scaled ppm) (ro) */
int64_t jitter; /* pps jitter (us) (ro) */
int32_t shift; /* interval duration (s) (shift) (ro) */
/* pad */
int64_t stabil; /* pps stability (scaled ppm) (ro) */
int64_t jitcnt; /* jitter limit exceeded (ro) */
int64_t calcnt; /* calibration intervals (ro) */
int64_t errcnt; /* calibration errors (ro) */
int64_t stbcnt; /* stability limit exceeded (ro) */
int32_t tai; /* TAI offset (ro) */
};
#define NSEC_PER_SEC 1000000000
static void ts_normalise(struct xn_timespec64 *ts)
......@@ -339,6 +372,38 @@ static int test_sc_cobalt_clock_getres64(void)
return 0;
}
static int test_sc_cobalt_clock_adjtime64(void)
{
int ret;
int sc_nr = sc_cobalt_clock_adjtime64;
struct xn_timex64 tx64 = {};
/* Make sure we don't crash because of NULL pointers */
ret = XENOMAI_SYSCALL2(sc_nr, NULL, NULL);
if (ret == -ENOSYS) {
smokey_note("clock_adjtime64: skipped. (no kernel support)");
return 0; // Not implemented, nothing to test, success
}
if (!smokey_assert(ret == -EFAULT))
return ret ? ret : -EINVAL;
/* Providing an invalid address has to deliver EFAULT */
ret = XENOMAI_SYSCALL2(sc_nr, CLOCK_REALTIME, (void *)0xdeadbeefUL);
if (!smokey_assert(ret == -EFAULT))
return ret ? ret : -EINVAL;
/* Provide a valid 64bit timex */
tx64.modes = ADJ_SETOFFSET;
tx64.time.tv_usec = 123;
ret = XENOMAI_SYSCALL2(sc_nr, CLOCK_REALTIME, &tx64);
/* adjtime is supported for external clocks only, expect EOPNOTSUPP */
if (!smokey_assert(ret == -EOPNOTSUPP))
return ret ? ret : -EINVAL;
return 0;
}
static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
{
int ret;
......@@ -363,5 +428,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
if (ret)
return ret;
ret = test_sc_cobalt_clock_adjtime64();
if (ret)
return ret;
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment