diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-08-04 03:51:17 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-08-04 03:51:17 +0200 |
commit | 01fc6533aa4175bad4b926361d017801aff9c53c (patch) | |
tree | c01a1315b2e41eb376a03436d1040bb0db30005e | |
parent | b4d4f8f8266e6407f21a62110905b27d3d3d71da (diff) | |
parent | 07d8fa58121be8fe315bd51ab760547fe209a745 (diff) | |
download | ffmpeg-01fc6533aa4175bad4b926361d017801aff9c53c.tar.gz |
Merge commit '07d8fa58121be8fe315bd51ab760547fe209a745'
* commit '07d8fa58121be8fe315bd51ab760547fe209a745':
fate: add informative cpu test
Conflicts:
tests/fate/libavutil.mak
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavutil/cpu.c | 49 | ||||
-rw-r--r-- | tests/fate/libavutil.mak | 3 |
2 files changed, 44 insertions, 8 deletions
diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 2d402117d0..62611878b2 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -279,6 +279,10 @@ int av_cpu_count(void) #include <stdio.h> +#if !HAVE_GETOPT +#include "compat/getopt.c" +#endif + static const struct { int flag; const char *name; @@ -322,17 +326,50 @@ static const struct { { 0 } }; -int main(void) +static void print_cpu_flags(int cpu_flags, const char *type) { - int cpu_flags = av_get_cpu_flags(); int i; - printf("cpu_flags = 0x%08X\n", cpu_flags); - printf("cpu_flags ="); + fprintf(stderr, "cpu_flags(%s) = 0x%08X\n", type, cpu_flags); + fprintf(stderr, "cpu_flags_str(%s) =", type); for (i = 0; cpu_flag_tab[i].flag; i++) if (cpu_flags & cpu_flag_tab[i].flag) - printf(" %s", cpu_flag_tab[i].name); - printf("\n"); + fprintf(stderr, " %s", cpu_flag_tab[i].name); + fprintf(stderr, "\n"); +} + + +int main(int argc, char **argv) +{ + int cpu_flags_raw = av_get_cpu_flags(); + int cpu_flags_eff; + + if (cpu_flags_raw < 0) + return 1; + + for (;;) { + int c = getopt(argc, argv, "c:"); + if (c == -1) + break; + switch (c) { + case 'c': + { + int cpuflags = av_parse_cpu_flags(optarg); + if (cpuflags < 0) + return 2; + av_set_cpu_flags_mask(cpuflags); + break; + } + } + } + + cpu_flags_eff = av_get_cpu_flags(); + + if (cpu_flags_eff < 0) + return 3; + + print_cpu_flags(cpu_flags_raw, "raw"); + print_cpu_flags(cpu_flags_eff, "effective"); return 0; } diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index 526ec16faf..8784cff019 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -31,9 +31,8 @@ fate-bprint: CMD = run libavutil/bprint-test FATE_LIBAVUTIL += fate-cpu fate-cpu: libavutil/cpu-test$(EXESUF) -fate-cpu: CMD = runecho libavutil/cpu-test +fate-cpu: CMD = run libavutil/cpu-test $(CPUFLAGS:%=-c%) fate-cpu: REF = /dev/null -fate-cpu: CMP = null FATE_LIBAVUTIL += fate-crc fate-crc: libavutil/crc-test$(EXESUF) |