Esempio n. 1
0
                pd[d['pid']] = d

    return pd


# ---------------------------------------------------------------------------
def get_cmd(pdir):
    f = open("%s/cmdline" % pdir)
    line = f.readline()
    f.close()
    rval = line.replace("\000", " ").strip()
    return rval


# ---------------------------------------------------------------------------
def get_ppid(pdir):
    f = open("%s/stat" % pdir)
    line = f.readline()
    f.close()
    rval = line.split()[3]
    return rval


# ---------------------------------------------------------------------------
def usage():
    print("usage: pstrack")
    sys.exit(1)

# ---------------------------------------------------------------------------
toolframe.ez_launch(__name__, main)
Esempio n. 2
0
        # print e, should_end
        assert(s == should_start)
        assert(e == should_end)
        
    def test_weekday_num(self):
        count = 0
        for d in ['monday', 'tuesday', 'wednesday', 'thursday', 'friday',
                  'saturday', 'sunday']:
            self.validate(weekday_num(d), count,
                          'weekday_num() fails for %s' % d)
            count = count + 1

        success = False
        try:
            x = weekday_num('notaday')
        except KeyError:
            success = True
        self.validate(success, True,
                      'should have gotten a KeyError for notaday')
        
    def validate(self, v1, v2, msg):
        try:
            assert(v1 == v2)
        except AssertionError:
            print msg
            print '%s =?= %s' % (v1, v2)
            raise
        
# ---------------------------------------------------------------------------
toolframe.ez_launch(main)
Esempio n. 3
0
    def test_zetta(self):
        self.magtest('43541873239090087685432 = 43.54 Zb')

    def test_bzetta(self):
        self.magtest('23487271233986700065432 = 19.89 Zib')

    def test_yotta(self):
        self.magtest('75843541873239090087685432 = 75.84 Yb')

    def test_byotta(self):
        self.magtest('39423487271233986700065432 = 32.61 Yib')

    def magtest(self, string):
        d = string.split()
        v = d[0]
        if 'i' in d[3]:
            args = ['./mag', '-b', v]
        else:
            args = ['./mag', v]
            
        a = main(args, True)
        try:
            assert(a == string)
        except AssertionError:
            print "\nexpected: '%s'" % a
            print "result:   '%s'" % string
        
# ---------------------------------------------------------------------------
toolframe.ez_launch()