File: debug_venv

package info (click to toggle)
python-ovsdbapp 2.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,040 kB
  • sloc: python: 9,222; sh: 138; makefile: 21
file content (63 lines) | stat: -rwxr-xr-x 1,774 bytes parent folder | download | duplicates (4)
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
57
58
59
60
61
62
63
#!/bin/sh
# Use a shell script to launch tools/debub_venv.py so that we can enter a
# virtual environment if we are not already in one

for option;do
    if test -n "$prev";then
        eval $prev=\$option
        prev=
        continue
    fi
    case $option in
        -v)
            if [ -n "$VIRTUAL_ENV" ]; then
                echo "Already in a virtual environment" 1>&2
                exit 1
            fi
            prev=venv ;;
        -o)
            prev=ovsvenv ;;
        -h|--help)
            cat << EOF
debug_venv: debug a test OVS virtual environment
usage: debug_venv [-v virtualenv] [-o ovsvenv | test_regex]"

Options:
  -v  The Python virtualenv to enter (defaults to 'functional')
  -o  The OVS virtual environment directory (precludes test_regex)
  test_regex An optionsal regular expression matching the test name to debug
EOF
            exit ;;
        *)
            if test -z "$regex";then
                regex=$option
            else
                echo "Only one regex" 1>&2
                exit 1
            fi
    esac
done

if [ -z "$regex" -a -z "$ovsvenv" ]; then
    echo "Need regex or ovsvenv" 1>&2
    exit 1
fi

if [ -z "$VIRTUAL_ENV" ]; then
    . .tox/${venv:-functional}/bin/activate
    trap deactivate EXIT
fi

if [ -n "$regex" -a -z "$ovsvenv" ]; then
    # Just do the first match for now
    lookup=$(grep $regex $VIRTUAL_ENV/ovsvenv.*|head -1)
    if [ -z "$lookup" ]; then
        echo "Could not match $regex" 1>&2
        exit 1
    fi
    test_file=$(echo $lookup|cut -d: -f1)
    test_match=", matched $(echo $lookup|rev|cut -d: -f1|rev)"
    ovsvenv=$(head -1 $test_file)
fi
echo "Debugging OVS virtual environment: $ovsvenv$test_match"
tools/debug_venv.py $ovsvenv $VIRTUAL_ENV/src/ovs $VIRTUAL_ENV/src/ovn