summaryrefslogtreecommitdiffstats
path: root/testsuite/config/unix.exp
blob: cfa17779d994706a00151286ffa9a9eb8bd755c2 (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
regexp "(.*\/)testsuite" $objdir objdir topdir


proc psmisc_v_version { tool } {
    global topdir
    set toolpath ${topdir}src/${tool}
    set tmp [ exec $toolpath -V 2>@1 ]
    regexp {\(PSmisc\) ([0-9a-z.-]+)} $tmp dummy version
    clone_output "$toolpath version $version\n"
}

proc fuser_version {}   { psmisc_v_version fuser }
proc killall_version {} { psmisc_v_version killall }
proc pslog_version {}   { psmisc_v_version pslog }
proc prtstat_version {} { psmisc_v_version prtstat }

proc expect_pass { testname reg } {
    expect {
        -re "$reg" { pass "$testname" }
        default { fail "$testname" }
                timeout { fail "$testname" }
    }
}

proc expect_nothing { test } {
	expect {
		-re "\\S" { fail "$test" }
    	eof { pass "$test" }
	}
}

proc kill_process pid {
    set cmdline "kill $pid"
    if { [catch { exec /bin/sh -c $cmdline } msg]} {
        warning "Could not kill process: $msg\n"
    }
}

proc make_socketproc { sktpath } {
    global topdir socketproc_pid socketproc_spawnid testsocket_path

    set testproc_realpath "${topdir}/src/socket_test"
    set socketproc_pid [ spawn $testproc_realpath $sktpath ]
}

proc kill_socketproc { } {
    global socketproc_pid
    kill_process $socketproc_pid
}