2008-02-28 02:42:31 +03:00
|
|
|
#include "splat-internal.h"
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-02-28 02:42:31 +03:00
|
|
|
#define SPLAT_SUBSYSTEM_TIME 0x0800
|
|
|
|
#define SPLAT_TIME_NAME "time"
|
|
|
|
#define SPLAT_TIME_DESC "Kernel Time Tests"
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-02-28 02:42:31 +03:00
|
|
|
#define SPLAT_TIME_TEST1_ID 0x0801
|
|
|
|
#define SPLAT_TIME_TEST1_NAME "time1"
|
|
|
|
#define SPLAT_TIME_TEST1_DESC "HZ Test"
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-02-28 02:42:31 +03:00
|
|
|
#define SPLAT_TIME_TEST2_ID 0x0802
|
|
|
|
#define SPLAT_TIME_TEST2_NAME "time2"
|
|
|
|
#define SPLAT_TIME_TEST2_DESC "Monotonic Test"
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
static int
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_time_test1(struct file *file, void *arg)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
|
|
|
int myhz = hz;
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_vprint(file, SPLAT_TIME_TEST1_NAME, "hz is %d\n", myhz);
|
2008-02-26 23:36:04 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_time_test2(struct file *file, void *arg)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
|
|
|
hrtime_t tm1, tm2;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
tm1 = gethrtime();
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_vprint(file, SPLAT_TIME_TEST2_NAME, "time is %lld\n", tm1);
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
for(i = 0; i < 100; i++) {
|
|
|
|
tm2 = gethrtime();
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_vprint(file, SPLAT_TIME_TEST2_NAME, "time is %lld\n", tm2);
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
if(tm1 > tm2) {
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_print(file, "%s: gethrtime() is not giving "
|
|
|
|
"monotonically increasing values\n",
|
|
|
|
SPLAT_TIME_TEST2_NAME);
|
2008-02-26 23:36:04 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
tm1 = tm2;
|
|
|
|
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
schedule_timeout(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_subsystem_t *
|
|
|
|
splat_time_init(void)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_subsystem_t *sub;
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
sub = kmalloc(sizeof(*sub), GFP_KERNEL);
|
|
|
|
if (sub == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
memset(sub, 0, sizeof(*sub));
|
2008-02-28 02:42:31 +03:00
|
|
|
strncpy(sub->desc.name, SPLAT_TIME_NAME, SPLAT_NAME_SIZE);
|
|
|
|
strncpy(sub->desc.desc, SPLAT_TIME_DESC, SPLAT_DESC_SIZE);
|
2008-02-26 23:36:04 +03:00
|
|
|
INIT_LIST_HEAD(&sub->subsystem_list);
|
|
|
|
INIT_LIST_HEAD(&sub->test_list);
|
|
|
|
spin_lock_init(&sub->test_lock);
|
2008-02-28 02:42:31 +03:00
|
|
|
sub->desc.id = SPLAT_SUBSYSTEM_TIME;
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-02-28 02:42:31 +03:00
|
|
|
SPLAT_TEST_INIT(sub, SPLAT_TIME_TEST1_NAME, SPLAT_TIME_TEST1_DESC,
|
|
|
|
SPLAT_TIME_TEST1_ID, splat_time_test1);
|
|
|
|
SPLAT_TEST_INIT(sub, SPLAT_TIME_TEST2_NAME, SPLAT_TIME_TEST2_DESC,
|
|
|
|
SPLAT_TIME_TEST2_ID, splat_time_test2);
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
return sub;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_time_fini(splat_subsystem_t *sub)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
|
|
|
ASSERT(sub);
|
|
|
|
|
2008-02-28 02:42:31 +03:00
|
|
|
SPLAT_TEST_FINI(sub, SPLAT_TIME_TEST2_ID);
|
|
|
|
SPLAT_TEST_FINI(sub, SPLAT_TIME_TEST1_ID);
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
kfree(sub);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_time_id(void)
|
2008-02-26 23:36:04 +03:00
|
|
|
{
|
2008-02-28 02:42:31 +03:00
|
|
|
return SPLAT_SUBSYSTEM_TIME;
|
2008-02-26 23:36:04 +03:00
|
|
|
}
|