Skip to content

Commit d66187c

Browse files
Yongjie2017H. Peter Anvin
authored andcommitted
reconstruct ffmpegtest to be generic to support more different projects
1 parent 9cb2329 commit d66187c

File tree

6 files changed

+70
-34
lines changed

6 files changed

+70
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ TAGS
9595
/test/perf/*.asm
9696
/test/testresults
9797
/test/ffmpegtest
98+
/test/x264test
9899
/version.h
99100
/version.mac
100101
/version.mak

test/Makefile.in

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ TESTS = $(wildcard *.asm)
1818
RM_F = rm -f
1919
RM_RF = rm -rf
2020

21-
.PHONY: tools nasm ndisasm ffmpegtest
21+
.PHONY: tools nasm ndisasm ffmpegtest x264test
2222
tools:
2323
$(MAKE) -C .. all
2424

@@ -29,7 +29,10 @@ $(NASM) $(NDISASM):
2929
$(MAKE) -C .. $(@F)
3030

3131
ffmpegtest:
32-
bash ffmpegtest.sh '$(NASM)'
32+
bash projtest.sh '$(NASM)' $@
33+
34+
x264test:
35+
bash projtest.sh '$(NASM)' $@
3336

3437
%.bin: %.asm $(NASM)
3538
$(NASM) $(NASMOPT) -f bin -o $@ -MD $@.dep -l $@.lst $<
@@ -108,7 +111,7 @@ clean:
108111
$(RM_F) *.aoutb
109112
$(RM_RF) testresults
110113
$(RM_F) elftest elftest64
111-
$(RM_RF) ffmpegtest
114+
$(RM_RF) ffmpegtest x264test
112115

113116
spotless: clean
114117
$(RM_RF) golden

test/get_build_ffmpegtest.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
: >> "$filelist"
4+
5+
if [ -d ffmpeg/.git ]; then
6+
cd ffmpeg
7+
git reset --hard
8+
xargs -r rm -f < "$filelist"
9+
else
10+
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
11+
cd ffmpeg
12+
fi
13+
: > "$filelist"
14+
./configure --disable-stripping
15+
ncpus=$(ls -1 /sys/bus/cpu/devices | wc -l)
16+
make -j${ncpus}

test/get_build_x264test.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
: >> "$filelist"
4+
5+
if [ -d x264/.git ]; then
6+
cd x264
7+
git reset --hard
8+
xargs -r rm -f < "$filelist"
9+
make clean
10+
else
11+
git clone https://code.videolan.org/videolan/x264.git x264
12+
cd x264
13+
fi
14+
: > "$filelist"
15+
./configure
16+
ncpus=$(ls -1 /sys/bus/cpu/devices | wc -l)
17+
make -j${ncpus}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
23
declare -a param1
34
declare -a param2
45
for p; do
@@ -7,17 +8,17 @@ for p; do
78
param1+=("$p.1" '-l' "$p.lst.1")
89
param2+=("$p.2" '-l' "$p.lst.2")
910
printf '%s\n%s.2\n%s.lst.2\n' "$ofile" "$ofile" "$ofile" \
10-
>> "$ffmpegnasm_filelist"
11+
>> "$projnasm_filelist"
1112
;;
1213
*) param1+=("$p")
1314
param2+=("$p")
1415
;;
1516
esac
1617
done
1718

18-
printf '%s\n' "$*" >> "$ffmpegnasm_logfile"
19+
printf '%s\n' "$*" >> "$projnasm_logfile"
1920

2021
rm -f "$ofile"
21-
"$ffmpegnasm_nasm1" "${param1[@]}" || exit $?
22-
"$ffmpegnasm_nasm2" "${param2[@]}" || exit $?
22+
"$projnasm_nasm1" "${param1[@]}" || exit $?
23+
"$projnasm_nasm2" "${param2[@]}" || exit $?
2324
cp -f "$ofile.1" "$ofile"

test/ffmpegtest.sh renamed to test/projtest.sh

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,54 @@ if [ -z "$NASM1" ]; then
88
echo 'Please install a reference nasm ...' 1>&2
99
exit 1
1010
fi
11+
1112
NASM2="$1"
1213
[ -z "$NASM2" ] && NASM2=../nasm
1314
NASM2=$(which "$NASM2" 2>/dev/null)
14-
1515
if [ -z "$NASM2" ]; then
1616
echo 'Test nasm not found' 1>&2
1717
exit 1
1818
fi
1919

20+
PROJ="$2"
21+
PROJ_GET_BUILD="get_build_${PROJ}.sh"
22+
if ! [ -f ${PROJ_GET_BUILD} ]; then
23+
echo 'No knowledge in building the project' 1>&2
24+
exit 1
25+
fi
26+
27+
export PATH=${PWD}:$PATH
28+
2029
set -x
2130

22-
mkdir -p "${there}/ffmpegtest"
23-
cd "${there}/ffmpegtest"
31+
mkdir -p "${there}/${PROJ}"
32+
cd "${there}/${PROJ}"
2433
here="$(pwd)"
2534

2635
logfile="$here/test.log"
2736
filelist="$here/file.list"
2837
rm -f "$logfile"
29-
export ffmpegnasm_logfile="$logfile"
30-
export ffmpegnasm_filelist="$filelist"
31-
export ffmpegnasm_nasm1="$NASM1"
32-
export ffmpegnasm_nasm2="$NASM2"
33-
34-
ffmpegnasm="$(realpath "$there/ffmpegnasm.sh")"
35-
36-
: >> "$filelist"
38+
export projnasm_logfile="$logfile"
39+
export projnasm_filelist="$filelist"
40+
export projnasm_nasm1="$NASM1"
41+
export projnasm_nasm2="$NASM2"
3742

38-
if [ -d ffmpeg/.git ]; then
39-
cd ffmpeg
40-
git reset --hard
41-
xargs -r rm -f < "$filelist"
42-
else
43-
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
44-
cd ffmpeg
45-
fi
46-
: > "$filelist"
47-
./configure --disable-stripping --x86asmexe="$ffmpegnasm"
48-
ncpus=$(ls -1 /sys/bus/cpu/devices | wc -l)
49-
make -j${ncpus}
43+
source ../${PROJ_GET_BUILD}
5044
rev=$?
51-
if [ "$?" -ne "0" ]; then
52-
echo ffmpeg compiling failed ...
45+
if [ "$rev" -ne "0" ]; then
46+
echo ${PROJ} compiling failed ...
5347
exit $rev
5448
fi
5549

5650
set +x
5751

5852
{
59-
for x in $(grep -o -P "\-o .*\.o" $logfile | sed -e 's/-o //' | grep -v "/ffconf")
53+
for x in $(grep -o -P "\-o .*\.o" $logfile | sed -e 's/-o //')
6054
do
55+
if ! [ -f $x ]; then
56+
# probably it's a temporary assembly being tested
57+
continue
58+
fi
6159
if ! [ -f ${x}.1 ]; then
6260
echo file ${x}.1 does not exist
6361
fi
@@ -78,6 +76,6 @@ do
7876
done
7977
} | tee "$here/results"
8078

81-
rev=$(grep -e " does not exist" -e "\[differs\]" $here/results >/dev/null)
79+
rev=$(! grep -e " does not exist" -e "\[differs\]" $here/results >/dev/null)
8280

8381
exit $rev

0 commit comments

Comments
 (0)