mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-24 07:46:42 +00:00
parent
cb6377355e
commit
b8ed80b7dd
@ -9,7 +9,7 @@ if {[expr ![have_include power_on/qemu]]} {
|
|||||||
|
|
||||||
set build_components {
|
set build_components {
|
||||||
core init timer drivers/rtc server/system_rtc test/system_rtc
|
core init timer drivers/rtc server/system_rtc test/system_rtc
|
||||||
server/report_rom
|
server/report_rom test/libc_rtc
|
||||||
}
|
}
|
||||||
|
|
||||||
build $build_components
|
build $build_components
|
||||||
@ -83,6 +83,20 @@ set config {
|
|||||||
<any-service> <parent/> </any-service>
|
<any-service> <parent/> </any-service>
|
||||||
</route>
|
</route>
|
||||||
</start>
|
</start>
|
||||||
|
|
||||||
|
<start name="test-libc_rtc" caps="150">
|
||||||
|
<resource name="RAM" quantum="4M"/>
|
||||||
|
<config>
|
||||||
|
<vfs> <dir name="dev"> <log/> <rtc/> </dir> </vfs>
|
||||||
|
<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"/>
|
||||||
|
</config>
|
||||||
|
<route>
|
||||||
|
<service name="Rtc"> <child name="system_rtc"/> </service>
|
||||||
|
<service name="Timer"> <child name="timer"/> </service>
|
||||||
|
<any-service> <parent/> </any-service>
|
||||||
|
</route>
|
||||||
|
</start>
|
||||||
|
|
||||||
</config>}
|
</config>}
|
||||||
|
|
||||||
install_config $config
|
install_config $config
|
||||||
@ -90,6 +104,7 @@ install_config $config
|
|||||||
set boot_components {
|
set boot_components {
|
||||||
core ld.lib.so init timer rtc_drv test-system_rtc system_rtc
|
core ld.lib.so init timer rtc_drv test-system_rtc system_rtc
|
||||||
report_rom
|
report_rom
|
||||||
|
test-libc_rtc libc.lib.so libm.lib.so posix.lib.so vfs.lib.so
|
||||||
}
|
}
|
||||||
|
|
||||||
build_boot_image $boot_components
|
build_boot_image $boot_components
|
||||||
|
46
repos/libports/src/test/libc_rtc/main.cc
Normal file
46
repos/libports/src/test/libc_rtc/main.cc
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* \brief Simple libc-based RTC test using clock_gettime()
|
||||||
|
* \author Martin Stein
|
||||||
|
* \date 2019-08-13
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU Affero General Public License version 3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
unsigned idx = 1;
|
||||||
|
while (1) {
|
||||||
|
struct timespec ts;
|
||||||
|
if (clock_gettime(0, &ts)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm *tm = localtime((time_t*)&ts.tv_sec);
|
||||||
|
if (!tm) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Timestamp #%d: %d-%d-%d %d:%d %ds\n",
|
||||||
|
idx++,
|
||||||
|
1900 + tm->tm_year,
|
||||||
|
1 + tm->tm_mon,
|
||||||
|
tm->tm_mday,
|
||||||
|
tm->tm_hour,
|
||||||
|
tm->tm_min,
|
||||||
|
tm->tm_sec);
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
7
repos/libports/src/test/libc_rtc/target.mk
Normal file
7
repos/libports/src/test/libc_rtc/target.mk
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
TARGET = test-libc_rtc
|
||||||
|
LIBS = posix
|
||||||
|
SRC_CC = main.cc
|
||||||
|
|
||||||
|
vpath main.cc $(PRG_DIR)
|
||||||
|
|
||||||
|
CC_CXX_WARN_STRICT =
|
Loading…
Reference in New Issue
Block a user