1#!/bin/sh
2
3kill_tlsdated() {
4	kill -TERM $PPID
5}
6
7result_passed() {
8	res=$(cat "$(mydir)"/"result")
9	if [ $res = "ok" ]; then
10		return 0
11	fi
12	return 1
13}
14
15check_err() {
16	grep -q "$1" "$(mydir)"/"run-err"
17}
18
19passed_if_timed_out() {
20	echo "ok" > "$(mydir)"/"result"
21}
22
23passed() {
24	echo "ok" > "$(mydir)"/"result"
25	kill_tlsdated
26}
27
28failed() {
29	echo "failed" > "$(mydir)"/"result"
30	kill_tlsdated
31}
32
33mydir() {
34	echo "$(dirname "$0")"
35}
36
37counter() {
38	cat "$(mydir)"/"$1"
39}
40
41inc_counter() {
42	c=$(counter "$1")
43	echo $((c + 1)) >"$(mydir)"/"$1"
44}
45
46reset_counter() {
47	echo 0 > "$(mydir)"/"$1"
48}
49
50reset_time() {
51	date +%s > "$(mydir)"/"$1"
52}
53
54emit_time() {
55	src/test/emit `cat "$(mydir)"/"$1"`
56}
57