Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / testing / tests / sanity / check_cksum.exp
1 #!/usr/bin/expect --
2 ################################################################################
3 #
4 # File:         check_cksum.exp
5 # Description:  Tests checksums of super files
6 # Author:       Andrew@DeFaria.com
7 # Created:      Fri Jun  6 15:37:15 PDT 2003
8 # Language:     Expect
9 # Test Class:   Sanity
10 #
11 # (c) Copyright 2003, Andrew@DeFaria.com, all rights reserved
12 #
13 ################################################################################
14 set test_base "/dview/defaria_default/Tools/testing"
15 source "$test_base/bin/TestPkg.tcl"
16
17 catch {namespace import Test::*}
18
19 proc Setup {} {
20   Start "check_cksum"
21
22   # Log into vxWorks...
23   LoginVxWorks
24
25   # Go to T drive, sanity folder
26   send "cd \"t:/sanity\"\r"
27
28   expect {
29     -gl "-> " {
30       return 0
31     }
32     timeout {
33       set Test::result 1
34       set Test::reason "Timedout trying to ct to \"t:/sanity\"!"
35       return 1
36     }
37       
38     default {
39       set Test::result 1
40       set Test::reason "Unable to cd to \"t:/sanity\"!"
41       return 1
42     }
43   }
44 }
45
46 proc Run {} {
47   set Test::result 0
48
49   # Get the names of the superfiles
50   set card_index 0
51
52   send "ls\r"
53
54   expect {
55     -gl "-> " {
56     }
57     timeout {
58       set Test::result 1
59       set Test::reason "Timedout executing ls!"
60       return 1
61     }
62     default {
63       set Test::result 1
64       set Test::reason "Unable to find images!"
65       return 1
66     }
67   }
68
69   set buf $expect_out(buffer)
70
71   # Extract superfile names
72   set index 2
73   set card [lindex $buf $index]
74
75   # Verifying checksums can take a while. Default timeout is 10 seconds.
76   # Unfortunately scc.sf takes longer than that. We will up the timeout
77   # to 25 seconds.
78   set timeout 25
79
80   while {$card != "value"} {
81     send "check_cksum \"$card\"\r"
82
83     expect {
84       -gl "-> " {
85       }
86       timeout {
87         set Test::result 1
88         set Test::reason "Timed out when executing check_cksum \"$card\""
89         break
90       }
91       default {
92         set Test::result 2
93         set Test:reason "check_cksum failed for card $card"
94         break
95       }
96     }
97     set index [expr $index+1]
98     set card [lindex $buf $index]
99   }
100   
101   # Restore default timeout
102   set timeout 10
103
104   return $Test::result
105 }
106
107 proc CleanUp {} {
108   # Logout of vxWorks
109   send "logout\r"
110
111   expect {
112     "Connection closed." {
113     }
114     default {
115       Warning "Unable to logout of vxWorks"
116     }
117   }
118
119   End
120 }
121
122 # Main
123 set setup_ok [Setup]
124
125 if {$setup_ok == 0} {
126   Run
127 }
128
129 CleanUp