[pulseaudio-discuss] [PATCH 5/5] add cpu test using the newly added test framework
Deng Zhengrong
dzrongg at gmail.com
Sun Jul 1 08:50:22 PDT 2012
---
src/Makefile.am | 6 ++++++
src/pulsecore/cpu-x86.c | 9 ++++++++-
src/pulsecore/cpu-x86.h | 1 +
src/tests/cpu-test.c | 31 +++++++++++++++++++++++++++++++
4 files changed, 46 insertions(+), 1 deletions(-)
create mode 100644 src/tests/cpu-test.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 0f4155d..98a3420 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -244,6 +244,7 @@ TESTS_default = \
volume-test \
mix-test \
proplist-test \
+ cpu-test \
lock-autospawn-test
TESTS_norun = \
@@ -483,6 +484,11 @@ proplist_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la li
proplist_test_CFLAGS = $(AM_CFLAGS)
proplist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
+cpu_test_SOURCES = tests/cpu-test.c
+cpu_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
+cpu_test_CFLAGS = $(AM_CFLAGS)
+cpu_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
+
rtstutter_SOURCES = tests/rtstutter.c
rtstutter_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
rtstutter_CFLAGS = $(AM_CFLAGS)
diff --git a/src/pulsecore/cpu-x86.c b/src/pulsecore/cpu-x86.c
index 05a4b2f..b778de2 100644
--- a/src/pulsecore/cpu-x86.c
+++ b/src/pulsecore/cpu-x86.c
@@ -44,7 +44,7 @@ static void get_cpuid(uint32_t op, uint32_t *a, uint32_t *b, uint32_t *c, uint32
}
#endif
-pa_bool_t pa_cpu_init_x86(pa_cpu_x86_flag_t *flags) {
+void pa_cpu_get_x86_flags(pa_cpu_x86_flag_t *flags) {
#if defined (__i386__) || defined (__amd64__)
uint32_t eax, ebx, ecx, edx;
uint32_t level;
@@ -98,6 +98,13 @@ pa_bool_t pa_cpu_init_x86(pa_cpu_x86_flag_t *flags) {
if (edx & (1<<31))
*flags |= PA_CPU_X86_3DNOW;
}
+#endif
+}
+
+pa_bool_t pa_cpu_init_x86(pa_cpu_x86_flag_t *flags) {
+ pa_cpu_get_x86_flags(flags);
+
+#if defined (__i386__) || defined (__amd64__)
pa_log_info("CPU flags: %s%s%s%s%s%s%s%s%s%s%s",
(*flags & PA_CPU_X86_CMOV) ? "CMOV " : "",
diff --git a/src/pulsecore/cpu-x86.h b/src/pulsecore/cpu-x86.h
index a797b65..715ed0d 100644
--- a/src/pulsecore/cpu-x86.h
+++ b/src/pulsecore/cpu-x86.h
@@ -41,6 +41,7 @@ typedef enum pa_cpu_x86_flag {
PA_CPU_X86_CMOV = (1 << 10)
} pa_cpu_x86_flag_t;
+void pa_cpu_get_x86_flags(pa_cpu_x86_flag_t *flags);
pa_bool_t pa_cpu_init_x86 (pa_cpu_x86_flag_t *flags);
#if defined (__i386__)
diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
new file mode 100644
index 0000000..ce7693d
--- /dev/null
+++ b/src/tests/cpu-test.c
@@ -0,0 +1,31 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <pulsecore/cpu-x86.h>
+#include <pulsecore/test.h>
+
+int main(int argc, char *argv[]) {
+ pa_cpu_x86_flag_t flags = 0;
+
+ pa_cpu_get_x86_flags(&flags);
+
+ if (flags & PA_CPU_X86_MMX) {
+ pa_test_suite mmx_suites[] = {
+ { svolume_mmx_unit_test },
+ };
+
+ pa_test_run_suites("mmx", mmx_suites);
+ }
+
+ if (flags & (PA_CPU_X86_SSE | PA_CPU_X86_SSE2)) {
+ pa_test_suite sse_suites[] = {
+ { sconv_sse_unit_test },
+ { svolume_sse_unit_test },
+ };
+
+ pa_test_run_suites("sse", sse_suites);
+ }
+
+ return 0;
+}
--
1.7.7.6
More information about the pulseaudio-discuss
mailing list