Skip to content
Snippets Groups Projects
Commit 9661e04e authored by Dor Laor's avatar Dor Laor
Browse files

Move the timer test code into its own file

parent 2a274e0f
No related branches found
No related tags found
No related merge requests found
......@@ -150,23 +150,6 @@ void* do_main_thread(void *_args)
drvman->load_all();
drvman->list_drivers();
auto t1 = clock::get()->time();
auto t2 = clock::get()->time();
debug(fmt("clock@t1 %1%") % t1);
debug(fmt("clock@t2 %1%") % t2);
timespec ts = {};
ts.tv_nsec = 100;
t1 = clock::get()->time();
nanosleep(&ts, nullptr);
t2 = clock::get()->time();
debug(fmt("nanosleep(100) -> %d") % (t2 - t1));
ts.tv_nsec = 100000;
t1 = clock::get()->time();
nanosleep(&ts, nullptr);
t2 = clock::get()->time();
debug(fmt("nanosleep(100000) -> %d") % (t2 - t1));
run_main(prog, args);
while (true)
......
#include "tst-hub.hh"
#include "tst-threads.hh"
#include "tst-malloc.hh"
#include "tst-timer.hh"
using namespace unit_tests;
void tests::execute_tests() {
test_threads threads;
test_malloc malloc;
test_timer timer;
instance().register_test(&threads);
instance().register_test(&malloc);
instance().register_test(&timer);
instance().run();
}
#ifndef __TST_TIMER__
#define __TST_TIMER__
#include "tst-hub.hh"
#include "drivers/clock.hh"
#include "debug.hh"
class test_timer : public unit_tests::vtest {
public:
void run()
{
auto t1 = clock::get()->time();
auto t2 = clock::get()->time();
debug(fmt("Timer test: clock@t1 %1%") % t1);
debug(fmt("Timer test: clock@t2 %1%") % t2);
timespec ts = {};
ts.tv_nsec = 100;
t1 = clock::get()->time();
nanosleep(&ts, nullptr);
t2 = clock::get()->time();
debug(fmt("Timer test: nanosleep(100) -> %d") % (t2 - t1));
ts.tv_nsec = 100000;
t1 = clock::get()->time();
nanosleep(&ts, nullptr);
t2 = clock::get()->time();
debug(fmt("Timer test: nanosleep(100000) -> %d") % (t2 - t1));
}
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment