[pulseaudio-discuss] [PATCH] tests: More useful output of 'make check'
Maarten Bosmans
mkbosmans at gmail.com
Mon Oct 3 12:17:24 PDT 2011
Instead of spilling thousands of lines of output, make check now runs the test-suite in about 100 lines or so.
Furthermore, the test suite now asserts on more failures, so that make check is more useful.
Several things are adressed:
- First of all: colors!
- Run some tests by default, because they return success or error
(extended-test, interpol-test, once-test, thread-test)
- Don't run some tests by default, because they only display information
(remix-test, sig2str)
- Change voltest to volume-test
- Some tests could use some speeding-up in order to limit the time needed for a make check.
- If running under make check, limit output of the test. The MAKE_CHECK environment variable
is used for this, so that when running the test manually, the full output is still shown.
(asyncq-test, interpol-test, ipacl-test, memblock-test, mix-test, once-test, prioq-test,
proplist-test, resampler-test, smoother-test, thread-test, volume-test)
- Make sure some tests assert on failures and return error status.
(extended-test, get-binary-name-test, ipacl-test)
---
configure.ac | 2 +-
src/.gitignore | 61 +++++++++---------
src/Makefile.am | 24 ++++---
src/tests/asyncmsgq-test.c | 16 ++--
src/tests/asyncq-test.c | 11 ++-
src/tests/extended-test.c | 2 +-
src/tests/get-binary-name-test.c | 10 ++-
src/tests/interpol-test.c | 27 +++-----
src/tests/ipacl-test.c | 113 +++++++++++---------------------
src/tests/lock-autospawn-test.c | 10 +--
src/tests/memblock-test.c | 49 ++++++++------
src/tests/memblockq-test.c | 30 ++++-----
src/tests/mix-test.c | 8 ++-
src/tests/once-test.c | 9 ++-
src/tests/prioq-test.c | 11 ++-
src/tests/proplist-test.c | 15 +++--
src/tests/resampler-test.c | 39 ++++++------
src/tests/rtpoll-test.c | 4 +-
src/tests/smoother-test.c | 11 ++-
src/tests/thread-mainloop-test.c | 2 -
src/tests/thread-test.c | 22 ++++---
src/tests/utf8-test.c | 6 +-
src/tests/voltest.c | 134 --------------------------------------
src/tests/volume-test.c | 134 ++++++++++++++++++++++++++++++++++++++
24 files changed, 363 insertions(+), 387 deletions(-)
delete mode 100644 src/tests/voltest.c
create mode 100644 src/tests/volume-test.c
diff --git a/configure.ac b/configure.ac
index 0bf40a8..d208f8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ AC_INIT([pulseaudio],[m4_esyscmd(./git-version-gen .tarball-version)],[mzchyfrnh
AC_CONFIG_SRCDIR([src/daemon/main.c])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules dist-xz tar-ustar])
+AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules color-tests dist-xz tar-ustar])
m4_define(pa_major, `echo $VERSION | cut -d. -f1 | cut -d- -f1`)
m4_define(pa_minor, `echo $VERSION | cut -d. -f2 | cut -d- -f1`)
diff --git a/src/.gitignore b/src/.gitignore
index 1e1822d..9bc6492 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,11 +1,4 @@
-once-test
-usergroup-test
-sigbus-test
TAGS
-alsa-time-test
-gtk-test
-prioq-test
-lock-autospawn-test
*.lo
*.o
*.la
@@ -13,59 +6,67 @@ lock-autospawn-test
.libs
Makefile
Makefile.in
-asyncmsgq-test
-asyncq-test
proximity-helper
-channelmap-test
client.conf
-close-test
-cpulimit-test
-cpulimit-test2
daemon.conf
default.pa
system.pa
esdcompat
-flist-test
gconf-helper
+pacat
+pacmd
+pactl
+paplay
+pasuspender
+pax11publish
+pulseaudio
+start-pulseaudio-x11
+start-pulseaudio-kde
+*-symdef.h
+*-orc-gen.[ch]
+# tests
+alsa-time-test
+asyncmsgq-test
+asyncq-test
+channelmap-test
+close-test
+connect-stress
+cpulimit-test
+cpulimit-test2
+extended-test
+flist-test
+format-test
get-binary-name-test
+gtk-test
hook-list-test
interpol-test
ipacl-test
+lock-autospawn-test
mainloop-test
mainloop-test-glib
mcalign-test
-memblock-test
memblockq-test
+memblock-test
mix-test
-pacat
+once-test
pacat-simple
-pacmd
-pactl
-paplay
parec-simple
-pasuspender
-pax11publish
+prioq-test
proplist-test
-pulseaudio
queue-test
remix-test
resampler-test
rtpoll-test
rtstutter
sig2str-test
+sigbus-test
smoother-test
stripnul
strlist-test
sync-playback
thread-mainloop-test
thread-test
+usergroup-test
utf8-test
-voltest
-start-pulseaudio-x11
-start-pulseaudio-kde
vector-test
-*-symdef.h
-connect-stress
-extended-test
-format-test
-*-orc-gen.[ch]
+volume-test
diff --git a/src/Makefile.am b/src/Makefile.am
index fdb2e99..1343b53 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -218,14 +218,15 @@ TESTS = \
mainloop-test \
strlist-test \
close-test \
- voltest \
vector-test \
memblockq-test \
channelmap-test \
thread-mainloop-test \
utf8-test \
+ extended-test \
format-test \
get-binary-name-test \
+ interpol-test \
ipacl-test \
hook-list-test \
memblock-test \
@@ -233,11 +234,11 @@ TESTS = \
asyncmsgq-test \
queue-test \
rtpoll-test \
- sig2str-test \
resampler-test \
smoother-test \
+ thread-test \
+ volume-test \
mix-test \
- remix-test \
proplist-test \
lock-autospawn-test \
prioq-test
@@ -246,12 +247,11 @@ TESTS_norun = \
mcalign-test \
pacat-simple \
parec-simple \
- extended-test \
sync-playback \
- interpol-test \
- thread-test \
flist-test \
+ remix-test \
rtstutter \
+ sig2str-test \
stripnul \
connect-stress
@@ -262,7 +262,7 @@ TESTS += \
endif
if !OS_IS_DARWIN
-TESTS_norun += \
+TESTS += \
once-test
endif
@@ -287,6 +287,8 @@ TESTS_norun += \
alsa-time-test
endif
+TESTS_ENVIRONMENT=MAKE_CHECK=1
+
if BUILD_TESTS_DEFAULT
noinst_PROGRAMS = $(TESTS) $(TESTS_norun)
else
@@ -398,10 +400,10 @@ close_test_CFLAGS = $(AM_CFLAGS)
close_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
close_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
-voltest_SOURCES = tests/voltest.c
-voltest_CFLAGS = $(AM_CFLAGS)
-voltest_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
-voltest_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
+volume_test_SOURCES = tests/volume-test.c
+volume_test_CFLAGS = $(AM_CFLAGS)
+volume_test_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
+volume_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
vector_test_SOURCES = tests/vector-test.c
vector_test_CFLAGS = $(AM_CFLAGS)
diff --git a/src/tests/asyncmsgq-test.c b/src/tests/asyncmsgq-test.c
index 96e5a0d..9fbe5bc 100644
--- a/src/tests/asyncmsgq-test.c
+++ b/src/tests/asyncmsgq-test.c
@@ -49,19 +49,19 @@ static void the_thread(void *_q) {
switch (code) {
case OPERATION_A:
- printf("Operation A\n");
+ pa_log_info("Operation A");
break;
case OPERATION_B:
- printf("Operation B\n");
+ pa_log_info("Operation B");
break;
case OPERATION_C:
- printf("Operation C\n");
+ pa_log_info("Operation C");
break;
case QUIT:
- printf("quit\n");
+ pa_log_info("quit");
quit = 1;
break;
}
@@ -79,22 +79,22 @@ int main(int argc, char *argv[]) {
pa_assert_se(t = pa_thread_new("test", the_thread, q));
- printf("Operation A post\n");
+ pa_log_info("Operation A post");
pa_asyncmsgq_post(q, NULL, OPERATION_A, NULL, 0, NULL, NULL);
pa_thread_yield();
- printf("Operation B post\n");
+ pa_log_info("Operation B post");
pa_asyncmsgq_post(q, NULL, OPERATION_B, NULL, 0, NULL, NULL);
pa_thread_yield();
- printf("Operation C send\n");
+ pa_log_info("Operation C send");
pa_asyncmsgq_send(q, NULL, OPERATION_C, NULL, 0, NULL);
pa_thread_yield();
- printf("Quit post\n");
+ pa_log_info("Quit post");
pa_asyncmsgq_post(q, NULL, QUIT, NULL, 0, NULL, NULL);
pa_thread_free(t);
diff --git a/src/tests/asyncq-test.c b/src/tests/asyncq-test.c
index 46bac9f..6ac8cba 100644
--- a/src/tests/asyncq-test.c
+++ b/src/tests/asyncq-test.c
@@ -36,12 +36,12 @@ static void producer(void *_q) {
int i;
for (i = 0; i < 1000; i++) {
- printf("pushing %i\n", i);
+ pa_log_debug("pushing %i", i);
pa_asyncq_push(q, PA_UINT_TO_PTR(i+1), 1);
}
pa_asyncq_push(q, PA_UINT_TO_PTR(-1), TRUE);
- printf("pushed end\n");
+ pa_log_debug("pushed end");
}
static void consumer(void *_q) {
@@ -59,16 +59,19 @@ static void consumer(void *_q) {
pa_assert(p == PA_UINT_TO_PTR(i+1));
- printf("popped %i\n", i);
+ pa_log_debug("popped %i", i);
}
- printf("popped end\n");
+ pa_log_debug("popped end");
}
int main(int argc, char *argv[]) {
pa_asyncq *q;
pa_thread *t1, *t2;
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
+
pa_assert_se(q = pa_asyncq_new(0));
pa_assert_se(t1 = pa_thread_new("producer", producer, q));
diff --git a/src/tests/extended-test.c b/src/tests/extended-test.c
index 631fdc8..0647aea 100644
--- a/src/tests/extended-test.c
+++ b/src/tests/extended-test.c
@@ -156,7 +156,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
int main(int argc, char *argv[]) {
pa_mainloop* m = NULL;
- int i, ret = 0;
+ int i, ret = 1;
for (i = 0; i < SAMPLE_HZ; i++)
data[i] = (float) sin(((double) i/SAMPLE_HZ)*2*M_PI*SINE_HZ)/2;
diff --git a/src/tests/get-binary-name-test.c b/src/tests/get-binary-name-test.c
index 4afe81b..7a09bc2 100644
--- a/src/tests/get-binary-name-test.c
+++ b/src/tests/get-binary-name-test.c
@@ -27,6 +27,8 @@
#include <pulse/util.h>
#include <pulse/xmalloc.h>
+#include <pulsecore/log.h>
+
int main(int argc, char *argv[]) {
char *exename;
size_t allocated = 128;
@@ -35,20 +37,20 @@ int main(int argc, char *argv[]) {
exename = pa_xmalloc(allocated);
if (!pa_get_binary_name(exename, allocated)) {
- printf("failed to read binary name\n");
+ pa_log_error("failed to read binary name");
pa_xfree(exename);
break;
}
if (strlen(exename) < allocated - 1) {
- printf("%s\n", exename);
+ pa_log("%s", exename);
pa_xfree(exename);
- break;
+ return 0;
}
pa_xfree(exename);
allocated *= 2;
}
- return 0;
+ return 1;
}
diff --git a/src/tests/interpol-test.c b/src/tests/interpol-test.c
index ffe4ab3..fa89e8e 100644
--- a/src/tests/interpol-test.c
+++ b/src/tests/interpol-test.c
@@ -25,13 +25,14 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
-#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <pulse/pulseaudio.h>
#include <pulse/mainloop.h>
+#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
#include <pulsecore/thread.h>
#define INTERPOLATE
@@ -87,7 +88,7 @@ static void stream_latency_cb(pa_stream *p, void *userdata) {
/* This is called whenever the context status changes */
static void context_state_callback(pa_context *c, void *userdata) {
- assert(c);
+ pa_assert(c);
switch (pa_context_get_state(c)) {
case PA_CONTEXT_CONNECTING:
@@ -118,7 +119,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
if (latency > 0)
flags |= PA_STREAM_ADJUST_LATENCY;
- fprintf(stderr, "Connection established.\n");
+ pa_log("Connection established");
pa_assert_se(stream = pa_stream_new(c, "interpol-test", &ss, NULL));
@@ -140,7 +141,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_FAILED:
default:
- fprintf(stderr, "Context error: %s\n", pa_strerror(pa_context_errno(c)));
+ pa_log_error("Context error: %s", pa_strerror(pa_context_errno(c)));
abort();
}
}
@@ -154,13 +155,11 @@ int main(int argc, char *argv[]) {
pa_bool_t corked = FALSE;
#endif
- pa_log_set_level(PA_LOG_DEBUG);
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
playback = argc <= 1 || !pa_streq(argv[1], "-r");
-
- latency =
- (argc >= 2 && !pa_streq(argv[1], "-r")) ? atoi(argv[1]) :
- (argc >= 3 ? atoi(argv[2]) : 0);
+ latency = (argc >= 2 && !pa_streq(argv[1], "-r")) ? atoi(argv[1]) : (argc >= 3 ? atoi(argv[2]) : 0);
/* Set up a new main loop */
pa_assert_se(m = pa_threaded_mainloop_new());
@@ -175,12 +174,7 @@ int main(int argc, char *argv[]) {
pa_assert_se(pa_threaded_mainloop_start(m) >= 0);
-/* #ifdef CORK */
- for (k = 0; k < 20000; k++)
-/* #else */
-/* for (k = 0; k < 2000; k++) */
-/* #endif */
- {
+ for (k = 0; k < 4000; k++) {
pa_bool_t success = FALSE, changed = FALSE;
pa_usec_t t, rtc, d;
struct timeval now, tv;
@@ -214,7 +208,7 @@ int main(int argc, char *argv[]) {
pa_bool_t cork_now;
#endif
rtc = pa_timeval_diff(&now, &start);
- printf("%i\t%llu\t%llu\t%llu\t%llu\t%lli\t%u\t%u\t%llu\t%llu\n", k,
+ pa_log_info("%i\t%llu\t%llu\t%llu\t%llu\t%lli\t%u\t%u\t%llu\t%llu\n", k,
(unsigned long long) rtc,
(unsigned long long) t,
(unsigned long long) (rtc-old_rtc),
@@ -245,7 +239,6 @@ int main(int argc, char *argv[]) {
}
/* Spin loop, ugly but normal usleep() is just too badly grained */
-
tv = now;
while (pa_timeval_diff(pa_gettimeofday(&now), &tv) < 1000)
pa_thread_yield();
diff --git a/src/tests/ipacl-test.c b/src/tests/ipacl-test.c
index be9caad..b3937d1 100644
--- a/src/tests/ipacl-test.c
+++ b/src/tests/ipacl-test.c
@@ -5,7 +5,6 @@
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
-#include <assert.h>
#include <string.h>
#ifdef HAVE_NETINET_IN_H
@@ -18,11 +17,24 @@
#include <netinet/ip.h>
#endif
-#include <pulsecore/socket.h>
+#include <pulsecore/log.h>
#include <pulsecore/macro.h>
+#include <pulsecore/socket.h>
#include <pulsecore/ipacl.h>
#include <pulsecore/arpa-inet.h>
+static void do_ip_acl_check(const char *s, int fd, int expected) {
+ pa_ip_acl *acl;
+ int result;
+
+ pa_assert_se(acl = pa_ip_acl_new(s));
+ result = pa_ip_acl_check(acl, fd);
+ pa_ip_acl_free(acl);
+
+ pa_log_info("%-20s result=%u (should be %u)", s, result, expected);
+ pa_assert(result == expected);
+}
+
int main(int argc, char *argv[]) {
struct sockaddr_in sa;
#ifdef HAVE_IPV6
@@ -30,63 +42,34 @@ int main(int argc, char *argv[]) {
#endif
int fd;
int r;
- pa_ip_acl *acl;
+
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
fd = socket(PF_INET, SOCK_STREAM, 0);
- assert(fd >= 0);
+ pa_assert(fd >= 0);
sa.sin_family = AF_INET;
sa.sin_port = htons(22);
sa.sin_addr.s_addr = inet_addr("127.0.0.1");
r = connect(fd, (struct sockaddr*) &sa, sizeof(sa));
- assert(r >= 0);
+ pa_assert(r >= 0);
- acl = pa_ip_acl_new("127.0.0.1");
- assert(acl);
- printf("result=%u (should be 1)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("127.0.0.2/0");
- assert(acl);
- printf("result=%u (should be 1)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("127.0.0.1/32");
- assert(acl);
- printf("result=%u (should be 1)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("127.0.0.1/7");
- assert(acl);
- printf("result=%u (should be 1)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("127.0.0.2");
- assert(acl);
- printf("result=%u (should be 0)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("127.0.0.0/8;0.0.0.0/32");
- assert(acl);
- printf("result=%u (should be 1)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("128.0.0.2/9");
- assert(acl);
- printf("result=%u (should be 0)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("::1/9");
- assert(acl);
- printf("result=%u (should be 0)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
+ do_ip_acl_check("127.0.0.1", fd, 1);
+ do_ip_acl_check("127.0.0.2/0", fd, 1);
+ do_ip_acl_check("127.0.0.1/32", fd, 1);
+ do_ip_acl_check("127.0.0.1/7", fd, 1);
+ do_ip_acl_check("127.0.0.2", fd, 0);
+ do_ip_acl_check("127.0.0.0/8;0.0.0.0/32", fd, 1);
+ do_ip_acl_check("128.0.0.2/9", fd, 0);
+ do_ip_acl_check("::1/9", fd, 0);
close(fd);
#ifdef HAVE_IPV6
if ( (fd = socket(PF_INET6, SOCK_STREAM, 0)) < 0 ) {
- printf("Unable to open IPv6 socket, IPv6 tests ignored");
+ pa_log_error("Unable to open IPv6 socket, IPv6 tests ignored");
return 0;
}
@@ -96,37 +79,15 @@ int main(int argc, char *argv[]) {
pa_assert_se(inet_pton(AF_INET6, "::1", &sa6.sin6_addr) == 1);
r = connect(fd, (struct sockaddr*) &sa6, sizeof(sa6));
- assert(r >= 0);
-
- acl = pa_ip_acl_new("::1");
- assert(acl);
- printf("result=%u (should be 1)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("::1/9");
- assert(acl);
- printf("result=%u (should be 1)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("::/0");
- assert(acl);
- printf("result=%u (should be 1)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("::2/128");
- assert(acl);
- printf("result=%u (should be 0)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("::2/127");
- assert(acl);
- printf("result=%u (should be 0)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
-
- acl = pa_ip_acl_new("::2/126");
- assert(acl);
- printf("result=%u (should be 1)\n", pa_ip_acl_check(acl, fd));
- pa_ip_acl_free(acl);
+ pa_assert(r >= 0);
+
+ do_ip_acl_check("::1", fd, 1);
+ do_ip_acl_check("::1", fd, 1);
+ do_ip_acl_check("::1/9", fd, 1);
+ do_ip_acl_check("::/0", fd, 1);
+ do_ip_acl_check("::2/128", fd, 0);
+ do_ip_acl_check("::2/127", fd, 0);
+ do_ip_acl_check("::2/126", fd, 1);
close(fd);
#endif
diff --git a/src/tests/lock-autospawn-test.c b/src/tests/lock-autospawn-test.c
index 9ba6129..a7324ab 100644
--- a/src/tests/lock-autospawn-test.c
+++ b/src/tests/lock-autospawn-test.c
@@ -38,9 +38,9 @@ static void thread_func(void*k) {
pa_assert_se(pa_autospawn_lock_acquire(TRUE) > 0);
- pa_log("%i, Got the lock!, Sleeping for 5s", PA_PTR_TO_INT(k));
+ pa_log("%i, Got the lock!, Sleeping for 2s", PA_PTR_TO_INT(k));
- pa_msleep(5000);
+ pa_msleep(2000);
pa_log("%i, Releasing", PA_PTR_TO_INT(k));
@@ -74,9 +74,9 @@ static void thread_func2(void *k) {
pa_log("%i, woke up", PA_PTR_TO_INT(k));
}
- pa_log("%i, Got the lock!, Sleeping for 5s", PA_PTR_TO_INT(k));
+ pa_log("%i, Got the lock!, Sleeping for 2s", PA_PTR_TO_INT(k));
- pa_msleep(5000);
+ pa_msleep(2000);
pa_log("%i, Releasing", PA_PTR_TO_INT(k));
@@ -103,7 +103,5 @@ int main(int argc, char**argv) {
pa_thread_free(c);
pa_thread_free(d);
- pa_log("End");
-
return 0;
}
diff --git a/src/tests/memblock-test.c b/src/tests/memblock-test.c
index a36ce22..b82c41a 100644
--- a/src/tests/memblock-test.c
+++ b/src/tests/memblock-test.c
@@ -24,33 +24,35 @@
#include <stdio.h>
#include <unistd.h>
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/log.h>
#include <pulsecore/memblock.h>
#include <pulsecore/macro.h>
-#include <pulse/xmalloc.h>
static void release_cb(pa_memimport *i, uint32_t block_id, void *userdata) {
- printf("%s: Imported block %u is released.\n", (char*) userdata, block_id);
+ pa_log("%s: Imported block %u is released.", (char*) userdata, block_id);
}
static void revoke_cb(pa_memexport *e, uint32_t block_id, void *userdata) {
- printf("%s: Exported block %u is revoked.\n", (char*) userdata, block_id);
+ pa_log("%s: Exported block %u is revoked.", (char*) userdata, block_id);
}
static void print_stats(pa_mempool *p, const char *text) {
const pa_mempool_stat*s = pa_mempool_get_stat(p);
- printf("%s = {\n"
- "n_allocated = %u\n"
- "n_accumulated = %u\n"
- "n_imported = %u\n"
- "n_exported = %u\n"
- "allocated_size = %u\n"
- "accumulated_size = %u\n"
- "imported_size = %u\n"
- "exported_size = %u\n"
- "n_too_large_for_pool = %u\n"
- "n_pool_full = %u\n"
- "}\n",
+ pa_log_debug("%s = {\n"
+ "\tn_allocated = %u\n"
+ "\tn_accumulated = %u\n"
+ "\tn_imported = %u\n"
+ "\tn_exported = %u\n"
+ "\tallocated_size = %u\n"
+ "\taccumulated_size = %u\n"
+ "\timported_size = %u\n"
+ "\texported_size = %u\n"
+ "\tn_too_large_for_pool = %u\n"
+ "\tn_pool_full = %u\n"
+ "}",
text,
(unsigned) pa_atomic_load(&s->n_allocated),
(unsigned) pa_atomic_load(&s->n_accumulated),
@@ -78,6 +80,9 @@ int main(int argc, char *argv[]) {
const char txt[] = "This is a test!";
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
+
pool_a = pa_mempool_new(TRUE, 0);
pool_b = pa_mempool_new(TRUE, 0);
pool_c = pa_mempool_new(TRUE, 0);
@@ -104,7 +109,7 @@ int main(int argc, char *argv[]) {
blocks[4] = NULL;
for (i = 0; blocks[i]; i++) {
- printf("Memory block %u\n", i);
+ pa_log("Memory block %u", i);
mb_a = blocks[i];
pa_assert(mb_a);
@@ -123,7 +128,7 @@ int main(int argc, char *argv[]) {
pa_assert(r >= 0);
pa_assert(shm_id == id_a);
- printf("A: Memory block exported as %u\n", id);
+ pa_log("A: Memory block exported as %u", id);
mb_b = pa_memimport_get(import_b, id, shm_id, offset, size);
pa_assert(mb_b);
@@ -132,12 +137,12 @@ int main(int argc, char *argv[]) {
pa_assert(shm_id == id_a || shm_id == id_b);
pa_memblock_unref(mb_b);
- printf("B: Memory block exported as %u\n", id);
+ pa_log("B: Memory block exported as %u", id);
mb_c = pa_memimport_get(import_c, id, shm_id, offset, size);
pa_assert(mb_c);
x = pa_memblock_acquire(mb_c);
- printf("1 data=%s\n", x);
+ pa_log_debug("1 data=%s", x);
pa_memblock_release(mb_c);
print_stats(pool_a, "A");
@@ -146,7 +151,7 @@ int main(int argc, char *argv[]) {
pa_memexport_free(export_b);
x = pa_memblock_acquire(mb_c);
- printf("2 data=%s\n", x);
+ pa_log_debug("2 data=%s", x);
pa_memblock_release(mb_c);
pa_memblock_unref(mb_c);
@@ -158,13 +163,13 @@ int main(int argc, char *argv[]) {
pa_memexport_free(export_a);
}
- printf("vacuuming...\n");
+ pa_log("vacuuming...");
pa_mempool_vacuum(pool_a);
pa_mempool_vacuum(pool_b);
pa_mempool_vacuum(pool_c);
- printf("vacuuming done...\n");
+ pa_log("vacuuming done...");
pa_mempool_free(pool_a);
pa_mempool_free(pool_b);
diff --git a/src/tests/memblockq-test.c b/src/tests/memblockq-test.c
index 085d70e..51e1717 100644
--- a/src/tests/memblockq-test.c
+++ b/src/tests/memblockq-test.c
@@ -22,12 +22,12 @@
#endif
#include <stdlib.h>
-#include <assert.h>
#include <stdio.h>
#include <signal.h>
#include <pulsecore/memblockq.h>
#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
static void dump_chunk(const pa_memchunk *chunk) {
size_t n;
@@ -38,7 +38,7 @@ static void dump_chunk(const pa_memchunk *chunk) {
q = pa_memblock_acquire(chunk->memblock);
for (e = (char*) q + chunk->index, n = 0; n < chunk->length; n++, e++)
- printf("%c", *e);
+ fprintf(stderr, "%c", *e);
pa_memblock_release(chunk->memblock);
}
@@ -48,14 +48,14 @@ static void dump(pa_memblockq *bq) {
pa_assert(bq);
/* First let's dump this as fixed block */
- printf("FIXED >");
+ fprintf(stderr, "FIXED >");
pa_memblockq_peek_fixed_size(bq, 64, &out);
dump_chunk(&out);
pa_memblock_unref(out.memblock);
- printf("<\n");
+ fprintf(stderr, "<\n");
/* Then let's dump the queue manually */
- printf("MANUAL>");
+ fprintf(stderr, "MANUAL>");
for (;;) {
if (pa_memblockq_peek(bq, &out) < 0)
@@ -66,7 +66,7 @@ static void dump(pa_memblockq *bq) {
pa_memblockq_drop(bq, out.length);
}
- printf("<\n");
+ fprintf(stderr, "<\n");
}
int main(int argc, char *argv[]) {
@@ -86,33 +86,27 @@ int main(int argc, char *argv[]) {
p = pa_mempool_new(FALSE, 0);
- silence.memblock = pa_memblock_new_fixed(p, (char*) "__", 2, 1);
- assert(silence.memblock);
+ pa_assert_se(silence.memblock = pa_memblock_new_fixed(p, (char*) "__", 2, 1));
silence.index = 0;
silence.length = pa_memblock_get_length(silence.memblock);
- bq = pa_memblockq_new("test memblockq", 0, 200, 10, &ss, 4, 4, 40, &silence);
- assert(bq);
+ pa_assert_se(bq = pa_memblockq_new("test memblockq", 0, 200, 10, &ss, 4, 4, 40, &silence));
- chunk1.memblock = pa_memblock_new_fixed(p, (char*) "11", 2, 1);
+ pa_assert_se(chunk1.memblock = pa_memblock_new_fixed(p, (char*) "11", 2, 1));
chunk1.index = 0;
chunk1.length = 2;
- assert(chunk1.memblock);
- chunk2.memblock = pa_memblock_new_fixed(p, (char*) "XX22", 4, 1);
+ pa_assert_se(chunk2.memblock = pa_memblock_new_fixed(p, (char*) "XX22", 4, 1));
chunk2.index = 2;
chunk2.length = 2;
- assert(chunk2.memblock);
- chunk3.memblock = pa_memblock_new_fixed(p, (char*) "3333", 4, 1);
+ pa_assert_se(chunk3.memblock = pa_memblock_new_fixed(p, (char*) "3333", 4, 1));
chunk3.index = 0;
chunk3.length = 4;
- assert(chunk3.memblock);
- chunk4.memblock = pa_memblock_new_fixed(p, (char*) "44444444", 8, 1);
+ pa_assert_se(chunk4.memblock = pa_memblock_new_fixed(p, (char*) "44444444", 8, 1));
chunk4.index = 0;
chunk4.length = 8;
- assert(chunk4.memblock);
ret = pa_memblockq_push(bq, &chunk1);
assert(ret == 0);
diff --git a/src/tests/mix-test.c b/src/tests/mix-test.c
index 7c05b8e..19b5ea5 100644
--- a/src/tests/mix-test.c
+++ b/src/tests/mix-test.c
@@ -35,6 +35,9 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
void *d;
unsigned i;
+ if (getenv("MAKE_CHECK"))
+ return;
+
d = pa_memblock_acquire(chunk->memblock);
switch (ss->format) {
@@ -202,7 +205,8 @@ int main(int argc, char *argv[]) {
pa_sample_spec a;
pa_cvolume v;
- pa_log_set_level(PA_LOG_DEBUG);
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
pa_assert_se(pool = pa_mempool_new(FALSE, 0));
@@ -217,7 +221,7 @@ int main(int argc, char *argv[]) {
pa_mix_info m[2];
void *ptr;
- printf("=== mixing: %s\n", pa_sample_format_to_string(a.format));
+ pa_log_debug("=== mixing: %s\n", pa_sample_format_to_string(a.format));
/* Generate block */
i.memblock = generate_block(pool, &a);
diff --git a/src/tests/once-test.c b/src/tests/once-test.c
index 8a9995d..cf33057 100644
--- a/src/tests/once-test.c
+++ b/src/tests/once-test.c
@@ -40,7 +40,7 @@ static pthread_barrier_t barrier;
#endif
static unsigned n_cpu;
-#define N_ITERATIONS 500
+#define N_ITERATIONS 200
#define N_THREADS 100
static void once_func(void) {
@@ -61,7 +61,7 @@ static void thread_func(void *data) {
pa_assert_se(pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) == 0);
#endif
- /* pa_log("started up: %s", data); */
+ pa_log_debug("started up: %s", (char *) data);
r = pthread_barrier_wait(&barrier);
pa_assert(r == 0 || r == PTHREAD_BARRIER_SERIAL_THREAD);
@@ -73,6 +73,9 @@ static void thread_func(void *data) {
int main(int argc, char *argv[]) {
unsigned n, i;
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
+
n_cpu = pa_ncpus();
for (n = 0; n < N_ITERATIONS; n++) {
@@ -92,7 +95,7 @@ int main(int argc, char *argv[]) {
pa_thread_join(threads[i]);
pa_assert(n_run == 1);
- pa_log("ran by %s", ran_by);
+ pa_log_info("ran by %s", ran_by);
for (i = 0; i < N_THREADS; i++) {
pa_xfree(pa_thread_get_data(threads[i]));
diff --git a/src/tests/prioq-test.c b/src/tests/prioq-test.c
index 120b512..bbcc92a 100644
--- a/src/tests/prioq-test.c
+++ b/src/tests/prioq-test.c
@@ -3,6 +3,7 @@
#endif
#include <pulsecore/prioq.h>
+#include <pulsecore/log.h>
#include <pulsecore/macro.h>
#define N 1024
@@ -13,6 +14,9 @@ int main(int argc, char *argv[]) {
srand(0);
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
+
q = pa_prioq_new(pa_idxset_trivial_compare_func);
/* Fill in 1024 */
@@ -22,20 +26,19 @@ int main(int argc, char *argv[]) {
/* Remove half of it again */
for (i = 0; i < N/2; i++){
unsigned u = PA_PTR_TO_UINT(pa_prioq_pop(q));
- pa_log("%16u", u);
+ pa_log_debug("%16u", u);
}
- pa_log("Refilling");
+ pa_log_debug("Refilling");
/* Fill in another 1024 */
for (i = 0; i < N; i++)
pa_prioq_put(q, PA_UINT_TO_PTR((unsigned) rand()));
-
/* Remove everything */
while (!pa_prioq_isempty(q)) {
unsigned u = PA_PTR_TO_UINT(pa_prioq_pop(q));
- pa_log("%16u", u);
+ pa_log_debug("%16u", u);
}
pa_prioq_free(q, NULL, NULL);
diff --git a/src/tests/proplist-test.c b/src/tests/proplist-test.c
index 8b5a235..f5a54d6 100644
--- a/src/tests/proplist-test.c
+++ b/src/tests/proplist-test.c
@@ -36,6 +36,9 @@ int main(int argc, char*argv[]) {
const char *text;
const char *x[] = { "foo", NULL };
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
+
a = pa_proplist_new();
pa_assert_se(pa_proplist_sets(a, PA_PROP_MEDIA_TITLE, "Brandenburgische Konzerte") == 0);
pa_assert_se(pa_proplist_sets(a, PA_PROP_MEDIA_ARTIST, "Johann Sebastian Bach") == 0);
@@ -48,12 +51,12 @@ int main(int argc, char*argv[]) {
pa_assert_se(!pa_proplist_gets(a, PA_PROP_MEDIA_ICON));
- printf("%s\n", pa_strnull(pa_proplist_gets(a, PA_PROP_MEDIA_TITLE)));
+ pa_log_debug("%s", pa_strnull(pa_proplist_gets(a, PA_PROP_MEDIA_TITLE)));
pa_assert_se(pa_proplist_unset(b, PA_PROP_MEDIA_TITLE) == 0);
s = pa_proplist_to_string(a);
t = pa_proplist_to_string(b);
- printf("---\n%s---\n%s", s, t);
+ pa_log_debug("---\n%s---\n%s", s, t);
c = pa_proplist_from_string(s);
u = pa_proplist_to_string(c);
@@ -69,16 +72,16 @@ int main(int argc, char*argv[]) {
text = " eins = zwei drei = \"\\\"vier\\\"\" fuenf=sechs sieben ='\\a\\c\\h\\t\\'\\\"' neun= hex:0123456789abCDef ";
- printf("%s\n", text);
+ pa_log_debug("%s", text);
d = pa_proplist_from_string(text);
v = pa_proplist_to_string(d);
pa_proplist_free(d);
- printf("%s\n", v);
+ pa_log_debug("%s", v);
d = pa_proplist_from_string(v);
pa_xfree(v);
v = pa_proplist_to_string(d);
pa_proplist_free(d);
- printf("%s\n", v);
+ pa_log_debug("%s", v);
pa_xfree(v);
pa_assert_se(ma = pa_modargs_new("foo='foobar=waldo foo2=\"lj\\\"dhflh\" foo3=\"kjlskj\\'\"'", x));
@@ -86,7 +89,7 @@ int main(int argc, char*argv[]) {
pa_assert_se(pa_modargs_get_proplist(ma, "foo", a, PA_UPDATE_REPLACE) >= 0);
- printf("%s\n", v = pa_proplist_to_string(a));
+ pa_log_debug("%s", v = pa_proplist_to_string(a));
pa_xfree(v);
pa_proplist_free(a);
diff --git a/src/tests/resampler-test.c b/src/tests/resampler-test.c
index 545c0e0..796cd52 100644
--- a/src/tests/resampler-test.c
+++ b/src/tests/resampler-test.c
@@ -32,6 +32,7 @@
#include <pulse/volume.h>
#include <pulsecore/i18n.h>
+#include <pulsecore/log.h>
#include <pulsecore/resampler.h>
#include <pulsecore/macro.h>
#include <pulsecore/endianmacros.h>
@@ -39,10 +40,14 @@
#include <pulsecore/sample-util.h>
#include <pulsecore/core-util.h>
-static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
+static void dump_block(const char *label, const pa_sample_spec *ss, const pa_memchunk *chunk) {
void *d;
unsigned i;
+ if (getenv("MAKE_CHECK"))
+ return;
+ printf("%s: \t", label);
+
d = pa_memblock_acquire(chunk->memblock);
switch (ss->format) {
@@ -297,7 +302,7 @@ int main(int argc, char *argv[]) {
pa_mempool *pool = NULL;
pa_sample_spec a, b;
pa_cvolume v;
- int ret = 1, verbose = 0, c;
+ int ret = 1, c;
pa_bool_t all_formats = TRUE;
pa_resample_method_t method;
int seconds;
@@ -321,7 +326,9 @@ int main(int argc, char *argv[]) {
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR);
- pa_log_set_level(PA_LOG_DEBUG);
+ pa_log_set_level(PA_LOG_WARN);
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_INFO);
pa_assert_se(pool = pa_mempool_new(FALSE, 0));
@@ -344,7 +351,6 @@ int main(int argc, char *argv[]) {
case 'v':
pa_log_set_level(PA_LOG_DEBUG);
- verbose = 1;
break;
case ARG_VERSION:
@@ -410,16 +416,14 @@ int main(int argc, char *argv[]) {
pa_memchunk i, j;
pa_usec_t ts;
- if (verbose) {
- printf(_("Compilation CFLAGS: %s\n"), PA_CFLAGS);
- printf(_("=== %d seconds: %d Hz %d ch (%s) -> %d Hz %d ch (%s)\n"), seconds,
+ pa_log_debug(_("Compilation CFLAGS: %s"), PA_CFLAGS);
+ pa_log_debug(_("=== %d seconds: %d Hz %d ch (%s) -> %d Hz %d ch (%s)"), seconds,
a.rate, a.channels, pa_sample_format_to_string(a.format),
b.rate, b.channels, pa_sample_format_to_string(b.format));
- }
ts = pa_rtclock_now();
pa_assert_se(resampler = pa_resampler_new(pool, &a, NULL, &b, NULL, method, 0));
- printf("init: %llu\n", (long long unsigned)(pa_rtclock_now() - ts));
+ pa_log_info("init: %llu", (long long unsigned)(pa_rtclock_now() - ts));
i.memblock = pa_memblock_new(pool, pa_usec_to_bytes(1*PA_USEC_PER_SEC, &a) / pa_frame_size(&a));
@@ -430,7 +434,7 @@ int main(int argc, char *argv[]) {
pa_resampler_run(resampler, &i, &j);
pa_memblock_unref(j.memblock);
}
- printf("resampling: %llu\n", (long long unsigned)(pa_rtclock_now() - ts));
+ pa_log_info("resampling: %llu", (long long unsigned)(pa_rtclock_now() - ts));
pa_memblock_unref(i.memblock);
pa_resampler_free(resampler);
@@ -443,8 +447,7 @@ int main(int argc, char *argv[]) {
pa_resampler *forth, *back;
pa_memchunk i, j, k;
- if (verbose)
- printf("=== %s -> %s -> %s -> /2\n",
+ pa_log_debug("=== %s -> %s -> %s -> /2",
pa_sample_format_to_string(a.format),
pa_sample_format_to_string(b.format),
pa_sample_format_to_string(a.format));
@@ -458,19 +461,15 @@ int main(int argc, char *argv[]) {
pa_resampler_run(forth, &i, &j);
pa_resampler_run(back, &j, &k);
- printf("before: ");
- dump_block(&a, &i);
- printf("after : ");
- dump_block(&b, &j);
- printf("reverse: ");
- dump_block(&a, &k);
+ dump_block("before", &a, &i);
+ dump_block("after", &b, &j);
+ dump_block("reverse", &a, &k);
pa_memblock_unref(j.memblock);
pa_memblock_unref(k.memblock);
pa_volume_memchunk(&i, &a, &v);
- printf("volume: ");
- dump_block(&a, &i);
+ dump_block("volume", &a, &i);
pa_memblock_unref(i.memblock);
diff --git a/src/tests/rtpoll-test.c b/src/tests/rtpoll-test.c
index 6a6b73a..4c862b2 100644
--- a/src/tests/rtpoll-test.c
+++ b/src/tests/rtpoll-test.c
@@ -23,6 +23,8 @@
#include <signal.h>
+#include <pulse/timeval.h>
+
#include <pulsecore/poll.h>
#include <pulsecore/log.h>
#include <pulsecore/rtpoll.h>
@@ -59,7 +61,7 @@ int main(int argc, char *argv[]) {
w = pa_rtpoll_item_new(p, PA_RTPOLL_NORMAL, 0);
pa_rtpoll_item_set_before_callback(w, worker);
- pa_rtpoll_set_timer_relative(p, 10000000); /* 10 s */
+ pa_rtpoll_set_timer_relative(p, 4 * PA_USEC_PER_SEC);
pa_rtpoll_run(p, 1);
diff --git a/src/tests/smoother-test.c b/src/tests/smoother-test.c
index 2cc9f58..4471669 100644
--- a/src/tests/smoother-test.c
+++ b/src/tests/smoother-test.c
@@ -24,9 +24,11 @@
#include <stdio.h>
#include <stdlib.h>
-#include <pulsecore/time-smoother.h>
#include <pulse/timeval.h>
+#include <pulsecore/log.h>
+#include <pulsecore/time-smoother.h>
+
int main(int argc, char*argv[]) {
pa_usec_t x;
unsigned u = 0;
@@ -45,7 +47,8 @@ int main(int argc, char*argv[]) {
srand(0);
- pa_log_set_level(PA_LOG_DEBUG);
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
for (m = 0, u = 0; u < PA_ELEMENTSOF(msec); u+= 2) {
@@ -67,13 +70,13 @@ int main(int argc, char*argv[]) {
while (u < PA_ELEMENTSOF(msec) && (pa_usec_t) msec[u]*PA_USEC_PER_MSEC < x) {
pa_smoother_put(s, (pa_usec_t) msec[u] * PA_USEC_PER_MSEC, (pa_usec_t) msec[u+1] * PA_USEC_PER_MSEC);
- printf("%i\t\t%i\n", msec[u], msec[u+1]);
+ pa_log_debug("%i\t\t%i", msec[u], msec[u+1]);
u += 2;
pa_smoother_resume(s, (pa_usec_t) msec[u] * PA_USEC_PER_MSEC, TRUE);
}
- printf("%llu\t%llu\n", (unsigned long long) (x/PA_USEC_PER_MSEC), (unsigned long long) (pa_smoother_get(s, x)/PA_USEC_PER_MSEC));
+ pa_log_debug("%llu\t%llu", (unsigned long long) (x/PA_USEC_PER_MSEC), (unsigned long long) (pa_smoother_get(s, x)/PA_USEC_PER_MSEC));
}
pa_smoother_free(s);
diff --git a/src/tests/thread-mainloop-test.c b/src/tests/thread-mainloop-test.c
index 7227597..599f195 100644
--- a/src/tests/thread-mainloop-test.c
+++ b/src/tests/thread-mainloop-test.c
@@ -67,8 +67,6 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "waiting 5s (sleep)\n");
pa_msleep(5000);
- fprintf(stderr, "shutting down\n");
-
pa_threaded_mainloop_stop(m);
pa_threaded_mainloop_free(m);
diff --git a/src/tests/thread-test.c b/src/tests/thread-test.c
index 4071e42..6441dc7 100644
--- a/src/tests/thread-test.c
+++ b/src/tests/thread-test.c
@@ -21,12 +21,13 @@
#include <config.h>
#endif
+#include <pulse/xmalloc.h>
#include <pulsecore/thread.h>
+#include <pulsecore/macro.h>
#include <pulsecore/mutex.h>
#include <pulsecore/once.h>
#include <pulsecore/log.h>
#include <pulsecore/core-util.h>
-#include <pulse/xmalloc.h>
static pa_mutex *mutex = NULL;
static pa_cond *cond1 = NULL, *cond2 = NULL;
@@ -45,14 +46,14 @@ static pa_once once = PA_ONCE_INIT;
static void thread_func(void *data) {
pa_tls_set(tls, data);
- pa_log("thread_func() for %s starting...", (char*) pa_tls_get(tls));
+ pa_log_info("thread_func() for %s starting...", (char*) pa_tls_get(tls));
pa_mutex_lock(mutex);
for (;;) {
int k, n;
- pa_log("%s waiting ...", (char*) pa_tls_get(tls));
+ pa_log_info("%s waiting ...", (char*) pa_tls_get(tls));
for (;;) {
@@ -74,7 +75,7 @@ static void thread_func(void *data) {
pa_cond_signal(cond2, 0);
- pa_log("%s got number %i", (char*) pa_tls_get(tls), k);
+ pa_log_info("%s got number %i", (char*) pa_tls_get(tls), k);
/* Spin! */
for (n = 0; n < k; n++)
@@ -87,21 +88,23 @@ quit:
pa_mutex_unlock(mutex);
- pa_log("thread_func() for %s done...", (char*) pa_tls_get(tls));
+ pa_log_info("thread_func() for %s done...", (char*) pa_tls_get(tls));
}
int main(int argc, char *argv[]) {
int i, k;
pa_thread* t[THREADS_MAX];
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
+
mutex = pa_mutex_new(FALSE, FALSE);
cond1 = pa_cond_new();
cond2 = pa_cond_new();
tls = pa_tls_new(pa_xfree);
for (i = 0; i < THREADS_MAX; i++) {
- t[i] = pa_thread_new("test", thread_func, pa_sprintf_malloc("Thread #%i", i+1));
- assert(t[i]);
+ pa_assert_se(t[i] = pa_thread_new("test", thread_func, pa_sprintf_malloc("Thread #%i", i+1)));
}
pa_mutex_lock(mutex);
@@ -109,12 +112,11 @@ int main(int argc, char *argv[]) {
pa_log("loop-init");
for (k = 0; k < 100; k++) {
- assert(magic_number == 0);
-
+ pa_assert(magic_number == 0);
magic_number = (int) rand() % 0x10000;
- pa_log("iteration %i (%i)", k, magic_number);
+ pa_log_info("iteration %i (%i)", k, magic_number);
pa_cond_signal(cond1, 0);
diff --git a/src/tests/utf8-test.c b/src/tests/utf8-test.c
index f1708ad..6dc5b50 100644
--- a/src/tests/utf8-test.c
+++ b/src/tests/utf8-test.c
@@ -13,11 +13,11 @@ int main(int argc, char *argv[]) {
assert(pa_utf8_valid("hallo\n"));
assert(pa_utf8_valid("hüpfburg\n"));
- printf("LATIN1: %s\n", c = pa_utf8_filter("hüpfburg"));
+ fprintf(stderr, "LATIN1: %s\n", c = pa_utf8_filter("hüpfburg"));
pa_xfree(c);
- printf("UTF8: %sx\n", c = pa_utf8_filter("hüpfburg"));
+ fprintf(stderr, "UTF8: %sx\n", c = pa_utf8_filter("hüpfburg"));
pa_xfree(c);
- printf("LATIN1: %sx\n", c = pa_utf8_filter("üxknärzmörzeltörszß³§dsjkfh"));
+ fprintf(stderr, "LATIN1: %sx\n", c = pa_utf8_filter("üxknärzmörzeltörszß³§dsjkfh"));
pa_xfree(c);
return 0;
diff --git a/src/tests/voltest.c b/src/tests/voltest.c
deleted file mode 100644
index b45a468..0000000
--- a/src/tests/voltest.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/***
- This file is part of PulseAudio.
-
- PulseAudio is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License,
- or (at your option) any later version.
-
- PulseAudio is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PulseAudio; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- USA.
-***/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <math.h>
-
-#include <pulse/volume.h>
-
-#include <pulsecore/macro.h>
-
-int main(int argc, char *argv[]) {
- pa_volume_t v;
- pa_cvolume cv;
- float b;
- pa_channel_map map;
- pa_volume_t md = 0;
- unsigned mdn = 0;
-
- printf("Attenuation of sample 1 against 32767: %g dB\n", 20.0*log10(1.0/32767.0));
- printf("Smallest possible attenuation > 0 applied to 32767: %li\n", lrint(32767.0*pa_sw_volume_to_linear(1)));
-
- for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 256) {
-
- double dB = pa_sw_volume_to_dB(v);
- double f = pa_sw_volume_to_linear(v);
-
- printf("Volume: %3i; percent: %i%%; decibel %0.2f; linear = %0.2f; volume(decibel): %3i; volume(linear): %3i\n",
- v, (v*100)/PA_VOLUME_NORM, dB, f, pa_sw_volume_from_dB(dB), pa_sw_volume_from_linear(f));
- }
-
- for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 256) {
- char s[PA_CVOLUME_SNPRINT_MAX], t[PA_SW_CVOLUME_SNPRINT_DB_MAX];
-
- pa_cvolume_set(&cv, 2, v);
-
- printf("Volume: %3i [%s] [%s]\n",
- v,
- pa_cvolume_snprint(s, sizeof(s), &cv),
- pa_sw_cvolume_snprint_dB(t, sizeof(t), &cv));
-
- }
-
- map.channels = cv.channels = 2;
- map.map[0] = PA_CHANNEL_POSITION_LEFT;
- map.map[1] = PA_CHANNEL_POSITION_RIGHT;
-
- for (cv.values[0] = PA_VOLUME_MUTED; cv.values[0] <= PA_VOLUME_NORM*2; cv.values[0] += 4096)
- for (cv.values[1] = PA_VOLUME_MUTED; cv.values[1] <= PA_VOLUME_NORM*2; cv.values[1] += 4096) {
- char s[PA_CVOLUME_SNPRINT_MAX];
-
- printf("Volume: [%s]; balance: %2.1f\n", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map));
- }
-
- for (cv.values[0] = PA_VOLUME_MUTED+4096; cv.values[0] <= PA_VOLUME_NORM*2; cv.values[0] += 4096)
- for (cv.values[1] = PA_VOLUME_MUTED; cv.values[1] <= PA_VOLUME_NORM*2; cv.values[1] += 4096)
- for (b = -1.0f; b <= 1.0f; b += 0.2f) {
- char s[PA_CVOLUME_SNPRINT_MAX];
- pa_cvolume r;
- float k;
-
- printf("Before: volume: [%s]; balance: %2.1f\n", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map));
-
- r = cv;
- pa_cvolume_set_balance(&r, &map,b);
-
- k = pa_cvolume_get_balance(&r, &map);
- printf("After: volume: [%s]; balance: %2.1f (intended: %2.1f) %s\n", pa_cvolume_snprint(s, sizeof(s), &r), k, b, k < b-.05 || k > b+.5 ? "MISMATCH" : "");
- }
-
- for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 51) {
-
- double l = pa_sw_volume_to_linear(v);
- pa_volume_t k = pa_sw_volume_from_linear(l);
- double db = pa_sw_volume_to_dB(v);
- pa_volume_t r = pa_sw_volume_from_dB(db);
- pa_volume_t w;
-
- pa_assert(k == v);
- pa_assert(r == v);
-
- for (w = PA_VOLUME_MUTED; w < PA_VOLUME_NORM*2; w += 37) {
-
- double t = pa_sw_volume_to_linear(w);
- double db2 = pa_sw_volume_to_dB(w);
- pa_volume_t p, p1, p2;
- double q, qq;
-
- p = pa_sw_volume_multiply(v, w);
- qq = db + db2;
- p2 = pa_sw_volume_from_dB(qq);
- q = l*t;
- p1 = pa_sw_volume_from_linear(q);
-
- if (p2 > p && p2 - p > md)
- md = p2 - p;
- if (p2 < p && p - p2 > md)
- md = p - p2;
- if (p1 > p && p1 - p > md)
- md = p1 - p;
- if (p1 < p && p - p1 > md)
- md = p - p1;
-
- if (p1 != p || p2 != p)
- mdn++;
- }
- }
-
- printf("max deviation: %lu n=%lu\n", (unsigned long) md, (unsigned long) mdn);
-
- pa_assert(md <= 1);
- pa_assert(mdn <= 251);
-
- return 0;
-}
diff --git a/src/tests/volume-test.c b/src/tests/volume-test.c
new file mode 100644
index 0000000..f7405ff
--- /dev/null
+++ b/src/tests/volume-test.c
@@ -0,0 +1,134 @@
+/***
+ This file is part of PulseAudio.
+
+ PulseAudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <math.h>
+
+#include <pulse/volume.h>
+
+#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
+
+int main(int argc, char *argv[]) {
+ pa_volume_t v;
+ pa_cvolume cv;
+ float b;
+ pa_channel_map map;
+ pa_volume_t md = 0;
+ unsigned mdn = 0;
+
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
+
+ pa_log("Attenuation of sample 1 against 32767: %g dB", 20.0*log10(1.0/32767.0));
+ pa_log("Smallest possible attenuation > 0 applied to 32767: %li", lrint(32767.0*pa_sw_volume_to_linear(1)));
+
+ for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 256) {
+
+ double dB = pa_sw_volume_to_dB(v);
+ double f = pa_sw_volume_to_linear(v);
+
+ pa_log_debug("Volume: %3i; percent: %i%%; decibel %0.2f; linear = %0.2f; volume(decibel): %3i; volume(linear): %3i",
+ v, (v*100)/PA_VOLUME_NORM, dB, f, pa_sw_volume_from_dB(dB), pa_sw_volume_from_linear(f));
+ }
+
+ for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 256) {
+ char s[PA_CVOLUME_SNPRINT_MAX], t[PA_SW_CVOLUME_SNPRINT_DB_MAX];
+
+ pa_cvolume_set(&cv, 2, v);
+
+ pa_log_debug("Volume: %3i [%s] [%s]", v, pa_cvolume_snprint(s, sizeof(s), &cv), pa_sw_cvolume_snprint_dB(t, sizeof(t), &cv));
+ }
+
+ map.channels = cv.channels = 2;
+ map.map[0] = PA_CHANNEL_POSITION_LEFT;
+ map.map[1] = PA_CHANNEL_POSITION_RIGHT;
+
+ for (cv.values[0] = PA_VOLUME_MUTED; cv.values[0] <= PA_VOLUME_NORM*2; cv.values[0] += 4096)
+ for (cv.values[1] = PA_VOLUME_MUTED; cv.values[1] <= PA_VOLUME_NORM*2; cv.values[1] += 4096) {
+ char s[PA_CVOLUME_SNPRINT_MAX];
+
+ pa_log_debug("Volume: [%s]; balance: %2.1f", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map));
+ }
+
+ for (cv.values[0] = PA_VOLUME_MUTED+4096; cv.values[0] <= PA_VOLUME_NORM*2; cv.values[0] += 4096)
+ for (cv.values[1] = PA_VOLUME_MUTED; cv.values[1] <= PA_VOLUME_NORM*2; cv.values[1] += 4096)
+ for (b = -1.0f; b <= 1.0f; b += 0.2f) {
+ char s[PA_CVOLUME_SNPRINT_MAX];
+ pa_cvolume r;
+ float k;
+
+ pa_log_debug("Before: volume: [%s]; balance: %2.1f", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map));
+
+ r = cv;
+ pa_cvolume_set_balance(&r, &map,b);
+
+ k = pa_cvolume_get_balance(&r, &map);
+ pa_log_debug("After: volume: [%s]; balance: %2.1f (intended: %2.1f) %s", pa_cvolume_snprint(s, sizeof(s), &r), k, b, k < b-.05 || k > b+.5 ? "MISMATCH" : "");
+ }
+
+ for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 51) {
+
+ double l = pa_sw_volume_to_linear(v);
+ pa_volume_t k = pa_sw_volume_from_linear(l);
+ double db = pa_sw_volume_to_dB(v);
+ pa_volume_t r = pa_sw_volume_from_dB(db);
+ pa_volume_t w;
+
+ pa_assert(k == v);
+ pa_assert(r == v);
+
+ for (w = PA_VOLUME_MUTED; w < PA_VOLUME_NORM*2; w += 37) {
+
+ double t = pa_sw_volume_to_linear(w);
+ double db2 = pa_sw_volume_to_dB(w);
+ pa_volume_t p, p1, p2;
+ double q, qq;
+
+ p = pa_sw_volume_multiply(v, w);
+ qq = db + db2;
+ p2 = pa_sw_volume_from_dB(qq);
+ q = l*t;
+ p1 = pa_sw_volume_from_linear(q);
+
+ if (p2 > p && p2 - p > md)
+ md = p2 - p;
+ if (p2 < p && p - p2 > md)
+ md = p - p2;
+ if (p1 > p && p1 - p > md)
+ md = p1 - p;
+ if (p1 < p && p - p1 > md)
+ md = p - p1;
+
+ if (p1 != p || p2 != p)
+ mdn++;
+ }
+ }
+
+ pa_log("max deviation: %lu n=%lu", (unsigned long) md, (unsigned long) mdn);
+
+ pa_assert(md <= 1);
+ pa_assert(mdn <= 251);
+
+ return 0;
+}
--
1.7.4.1
More information about the pulseaudio-discuss
mailing list