1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-09-29 04:25:57 -04:00

Feature: Added ctest for timing module

This commit is contained in:
Philipp Schafft 2019-08-21 16:05:29 +00:00
parent 1d55a731ff
commit eaf71d262b
2 changed files with 53 additions and 0 deletions

View File

@ -73,5 +73,10 @@ ctest_logmsg_test_LDADD = libice_ctest.la \
src/logmsg.o src/logmsg.o
check_PROGRAMS += ctest_logmsg.test check_PROGRAMS += ctest_logmsg.test
ctest_timing_test_SOURCES = %reldir%/ctest_timing.c
ctest_timing_test_LDADD = libice_ctest.la \
src/timing.o
check_PROGRAMS += ctest_timing.test
# Add all programs to TESTS # Add all programs to TESTS
TESTS = $(check_PROGRAMS) TESTS = $(check_PROGRAMS)

48
src/tests/ctest_timing.c Normal file
View File

@ -0,0 +1,48 @@
/* Icecast
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2018, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include "ctest_lib.h"
#include <igloo/timing.h>
static void test_get_time(void)
{
uint64_t a, b;
a = igloo_timing_get_time();
b = igloo_timing_get_time();
ctest_test("Time increases", a <= b);
}
static void test_sleep(void)
{
uint64_t a, b;
a = igloo_timing_get_time();
igloo_timing_sleep(128);
b = igloo_timing_get_time();
ctest_test("Slept", (a < b) && ((a + 256) > b));
}
int main (void)
{
ctest_init();
test_get_time();
test_sleep();
ctest_fin();
return 0;
}