Debian Codegraph @

debian/tests/pfftools

raw
1 #!/bin/bash
2
3 TESTS="test_pffexport.sh test_pffinfo.sh"
4 SAMPLE_FILE="outlook.pst"
5 SAMPLE_URL="https://github.com/libyal/testdata/blob/main/pst/${SAMPLE_FILE}?raw=true"
6 SCRIPT_DIR="$(dirname "$0")"
7 SRC_DIR="$(cd "$SCRIPT_DIR/../../tests" && pwd)"
8 TESTS_DIR=$AUTOPKGTEST_TMP/tests
9 TOTAL_LOG=$AUTOPKGTEST_ARTIFACTS/total.log
10 SAMPLE_PATH=$TESTS_DIR/input/public/$SAMPLE_FILE
11
12 dload_sample()
13 {
14 url="$1"
15 dst="$2"
16 mkdir -p "$(dirname "$TESTS_DIR/$dst")"
17 if test -f "$SRC_DIR/$dst"; then
18 cp "$SRC_DIR/$dst" "$TESTS_DIR/$dst"
19 else
20 echo "Downloading $dst"
21 curl -L -k --silent --show-error -o "$TESTS_DIR/$dst" "$url" 2>&1
22 fi
23 }
24
25 prepare_test_dir()
26 {
27 dload_sample "$SAMPLE_URL" "input/public/$SAMPLE_FILE"
28 mkdir -p "$AUTOPKGTEST_TMP/pfftools" "$TESTS_DIR"
29 ln -s /usr/bin/pffexport "$AUTOPKGTEST_TMP/pfftools/pffexport"
30 ln -s /usr/bin/pffinfo "$AUTOPKGTEST_TMP/pfftools/pffinfo"
31 cd "$SRC_DIR" && cp $TESTS test_runner.sh "$TESTS_DIR/"
32 }
33
34 run_test()
35 {
36 script="$1"
37 name=$(basename $1)
38 logfile="$AUTOPKGTEST_ARTIFACTS/$(basename "$script.log")"
39
40 $script > $logfile 2>&1
41 exitstatus=$?
42 case $exitstatus in
43 0) text=PASS; success=1;;
44 77) text=SKIP; success=1;;
45 99) text=ERROR; success=0;;
46 *) text=FAIL; success=0;;
47 esac
48
49 echo $text: $name
50 if test $success -ne 1; then
51 echo "Logfile: $logfile" >> $TOTAL_LOG
52 cat $logfile >> $TOTAL_LOG
53 echo >> $TOTAL_LOG
54 fi
55 }
56
57 if prepare_test_dir && test -f $SAMPLE_PATH; then
58 RES=0
59 cd $TESTS_DIR
60 for TEST in $TESTS; do
61 run_test $TESTS_DIR/$TEST
62 done
63 cd $SRC_DIR
64 test -f $TOTAL_LOG && cat $TOTAL_LOG && RES=1
65 exit $RES
66 else
67 echo "Sample file not found: $SAMPLE_PATH"
68 exit 2
69 fi