Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7b42d40f3758cfd4c22214b17559daefa5ae7a7c
[simgrid.git] / tools / tesh2 / examples / var.tesh
1 #! ./tesh
2 # This file describes the usage of the Tesh variables and contains all the tests connected.
3
4 # Description of this tesh suite
5 D Usage of tesh variables
6
7 # Declare and define the variable include-file
8 ! include-file=catch-signal.tesh
9
10 # include the tesh file specified by the value (catch-signal.tesh) of the variable include-file
11 ! include $include-file
12
13 # set a new value to the variable include-file
14 ! include-file=basic.tesh
15
16 # this line throws a warning (you assign the same value to the variable)
17 ! include-file=basic.tesh
18
19 # include the tesh file specified by the value (basic.tesh) of the variable include-file
20 ! include $include-file
21
22 # Undefined variable
23 ! expect return $ESYNTAX
24 < ! include-file=
25 < ! include $include-file
26 $ ./tesh --log="log.thresh:info tesh.fmt:%m%n"
27 > Test unit from stdin
28 > [stdin:1] Undefined variable `(include-file)'
29 > Test unit `stdin': NOK (<stdin:1> syntax error)
30
31
32 # A single sample of the usage of the tesh variables
33 $ rm -rf temp_testdir
34 $ mkdir temp_testdir
35
36 $ cd temp_testdir
37
38 < #include <stdlib.h>
39 < #include <stdio.h>
40 < int main(int argc, char* argv[]) {    
41 <       return ( atoi(argv[1]) + atoi(argv[2]));
42 <       }  
43 $ cat > sum.c
44
45 $ gcc -o sum sum.c
46
47 ! x=2
48 ! y=2
49 ! sum=./sum
50 ! rv=4
51
52 ! expect return $rv
53 $ $sum $x $y
54
55 $ cd ..
56 $ rm -rf temp_testdir
57
58 # set metacommand usage
59
60 # This ligne add a new tesh variable DIR
61
62 ! set DIR=temp_testdir
63
64 $ rm -rf $DIR
65
66 $ mkdir $DIR
67
68 $ cd $DIR
69
70 $ cd ..
71
72 $ rm -rf $DIR
73
74 # This ligne change the value of the tesh variable DIR
75 ! set DIR=test_tempdir
76
77 # This ligne # this line throws a warning (you assign the same value to the variable)
78 ! set DIR=test_tempdir
79
80
81 # This ligne create a new variable CURRENT_DIR (setted with the content of the variable DIR)
82 ! CURRENT_DIR=$DIR
83 p CURRENT_DIR is $CURRENT_DIR (same value as DIR)
84
85 # This ligne use the metacommand `set' to update the content of the variable CURRENT_DIR
86 ! set CURRENT_DIR=temp_testdir
87 p Now CURRENT_DIR is $CURRENT_DIR
88
89 # This ligne unset the variable CURRENT_DIR (delete the tesh variable)
90 ! unset CURRENT_DIR
91 p $CURRENT_DIR does not exist
92
93 # This ligne displays the content of the environment variable TESH_PPID (which contains the PID of the tesh parent) 
94 p The Tesh parent PID is: $TESH_PPID
95
96 # This ligne displays the content of the value of the system variable ENOENT
97 p On this platform ENOENT is: $ENOENT
98
99 # Attempt to change the content of a system variable is a syntax error
100 ! expect return $ESYNTAX
101 < ! ENOENT=300
102 < $ echo $ENOENT
103 $ ./tesh --log="log.thresh:info tesh.fmt:%m%n"
104 > Test unit from stdin
105 > [stdin:1] A system variable named `(ENOENT)' already exists
106 > Test unit `stdin': NOK (<stdin:1> syntax error)
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131