aboutsummaryrefslogtreecommitdiff
path: root/bisect/unit_test.sh
blob: f842e7ed8902cbd13e50a4f9217891b2a5917afe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash

rev_file=.unit.rev
if [ "$1" = "" ]; then
  echo "For bisect.pl testing."
  echo
  echo "Usage:"
  echo "./bisect.pl -c "unit_test -c" \\"
  echo "            -b "unit_test -b BAD_COMPILATION_REV" \\"
  echo "            -t "unit_test -t BAD_TEST_REV" \\"
  echo "            start_rev stop_rev"
  echo
  echo "So that you can make sure that BAD_COMPILATION_REV"
  echo "does't break the bisect looking for BAD_TEST_REV."
  rm -f $rev_file
  exit 0
fi

# Replaces checkout.sh REV
# Dummy print revision to temp file
if [ "$1" = "-c" ]; then
  echo $2 > $rev_file
  exit 0
fi

# From here on, we assume the temp file exists
if [ ! -f $rev_file ]; then
  echo "Use unit_checkout.sh REV first"
  exit 1
fi
REV=`cat $rev_file`
echo "Testing revision $REV..."

# Replaces run.sh
# Dummy check for temp rev, compares to fake broken arg
if [ "$1" = "-b" ]; then
  if [ "$2" = "$REV" ]; then
    echo "Bad compilation"
    exit 1
  else
    echo "Good compilation"
    exit 0
  fi
fi

# Replaces test.sh
# Dummy check for temp rev, compares to fake broken arg
if [ "$1" = "-t" ]; then
  if [ $REV -ge $2 ]; then
    echo "Bad test"
    exit 1
  else
    echo "Good test"
    exit 0
  fi
fi