File: lfc_setatime_test.py

package info (click to toggle)
dpm-postgres 1.7.4.7-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 13,788 kB
  • ctags: 10,782
  • sloc: ansic: 146,136; sh: 13,362; perl: 11,142; python: 5,529; cpp: 5,113; sql: 1,790; makefile: 955; fortran: 113
file content (59 lines) | stat: -rw-r--r-- 1,805 bytes parent folder | download | duplicates (8)
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
53
54
55
56
57
58
59
import os, lfc, sys, commands
from testClass import _test, _ntest

global testHome 

class test_setatime_ok(_test):
    def info(self):
        return "Set file size on existing file name"
    def prepare(self):
        guid = commands.getoutput('uuidgen').split('/n')[0]
        self.name = "/grid/dteam/python_setatime_test"
        ret = lfc.lfc_creatg(self.name,guid,0664)
        self.start=lfc.lfc_filestat()
        lfc.lfc_stat(self.name, self.start)
        
    def clean(self):
        lfc.lfc_unlink(self.name)
    def test(self):
        ret=lfc.lfc_setatime(self.name,None)
        stat=lfc.lfc_filestat()
        lfc.lfc_stat(self.name, stat)
        return (stat,ret)
    def ret(self):
        return self.start
    def compare(self, testVal, retVal):
        (ret, retRetVal) = retVal
        (test, testRetVal) = testVal
        retval = True
        if (retRetVal == testRetVal):
            retval = retval & ( test.atime != ret.atime )
        else:
            retval = False
        return retval


class lfc_setatime_test:
    def __init__(self):
	self.name = "lfc_setatime_test"
        self.tests=[test_setatime_ok]

    def run(self):
        retVal = True
        for testclass in self.tests:
            testInstance = testclass()
            testInstance.prepare()
            ret1 = testInstance.compare(testInstance.test(), (testInstance.ret(), testInstance.getRetVal()))
            testInstance.clean()
            retVal = retVal & ret1
            if ret1:
                print "%-60s[OK]" % testInstance.info()
            else:
                print "%-60s[FAILED]" % testInstance.info()
        return retVal


os.environ['LFC_HOME'] = 'lxb1941.cern.ch:/grid/dteam'
os.environ['LFC_HOST'] = 'lxb1941.cern.ch'
testHome = "python_lfc_test"
lfc_setatime_test().run()