apw | 6e55162 | 2006-04-04 08:50:53 +0000 | [diff] [blame^] | 1 | import test |
| 2 | from autotest_utils import * |
| 3 | from error import * |
| 4 | |
| 5 | class selftest(test.test): |
| 6 | def setup(self): |
| 7 | name = self.job.resultdir + '/sequence' |
| 8 | if (not os.path.exists(name)): |
| 9 | fd = file(name, 'w') |
| 10 | fd.write('0') |
| 11 | fd.close() |
| 12 | |
| 13 | def execute(self, checkpoint): |
| 14 | name = self.job.resultdir + '/sequence' |
| 15 | fd = file(name, 'r') |
| 16 | current = int(fd.readline()) |
| 17 | fd.close() |
| 18 | |
| 19 | current += 1 |
| 20 | fd = file(name + '.new', 'w') |
| 21 | fd.write('%d' % current) |
| 22 | fd.close() |
| 23 | |
| 24 | os.rename(name + '.new', name) |
| 25 | |
| 26 | print "checkpoint %d %d" % (current, checkpoint) |
| 27 | |
| 28 | if (current != checkpoint): |
| 29 | raise JobError("selftest: sequence was " + |
| 30 | "%d when %d expected" % (current, checkpoint)) |