Debian Codegraph @

testsuite/systemtap.language_server/langserver.exp

raw
1 # Test the language server.
2 set test "language_server"
3 global env
4 set PYTHON3 $env(PYTHON3)
5
6 # Both python and jsonc are required
7 if {! [file exists "$PYTHON3"]} then { untested $test; return }
8 if { [catch {exec pkg-config json-c }] } then { untested $test; return }
9 if {[strverscmp $GCC_Version 8] < 0} {
10 verbose -log "skipping $test.exp: GCC too old ($GCC_Version vs. 8)"
11 untested $test
12 return
13 }
14
15 set test_root "$srcdir/$subdir"
16 set test_script "$test_root/stap_language_server_tester.py"
17
18 # This is used for testing string completion
19 set file_dir "$test_root/foo/bar"
20 set exe_name "baz"
21 set file_path "$file_dir/$exe_name.c"
22
23 set result [target_compile $file_path $file_dir/$exe_name executable "compiler=gcc additional_flags=-g"]
24 if { $result != "" } {
25 fail "${test}: unable to compile $exe_name.c"
26 }
27
28 set env(TEST_PATH) "$test_root/"
29 set env(TEST_C_FILE) $file_path
30 # Prevent the creation of __pycache__
31 set env(PYTHONDONTWRITEBYTECODE) 1
32
33 set v "-v"
34 if { $verbose == 0 } {
35 set v "-vvv"
36 }
37
38 # The testing suite can be run independently for development
39 # See: stap_language_server_tester.py --help
40
41 # By default TCL considers any output to stderr to be an error and causes rc to be 1
42 # A simple work around is to redirect stderr to stdout and this removes that behaviour
43 set rc [catch {exec $PYTHON3 $test_script "--stap-path=$env(SYSTEMTAP_PATH)/stap" $v 2>@stdout } out]
44 if { $rc } {
45 verbose -log "$test test failure: $out";
46 fail $test;
47 } else {
48 pass $test;
49 }
50
51 # Cleanup
52 set env(TEST_PATH) ""
53 set env(TEST_C_FILE) ""
54 set env(PYTHONDONTWRITEBYTECODE) 0
55 catch { exec rm -f $file_dir/$exe_name}