Esempio n. 1
0
    def test(self, dirname, binary, fin, fout):
        self.info("Testing %s ... " % fin, newline=False)
        start = datetime.now()
        prog = 'cat %s | %s' % (fin, binary)
        proc = Popen(prog, stdout=PIPE, stderr=PIPE, shell=True)
        out, err = proc.communicate()
        result = out.strip()
        timedelta = datetime.now() - start

        prog2 = 'cat %s' % fout
        proc2 = Popen(prog2, stdout=PIPE, stderr=PIPE, shell=True)
        out2, err2 = proc2.communicate()
        expected = out2.strip()

        success = result == expected and proc.returncode == 0 and proc2.returncode == 0
        if success:
            self.success_continuation('OK [%.3f]s' % get_total_seconds(timedelta))
        else:
            self.error_continuation('Fail')
            if self.namespace.verbose:
                if proc.returncode != 0:
                    msg = "    Program returned with code %d:\n%s" % (
                        proc.returncode, err)
                else:
                    msg = "    Result was:\n%s\n but expected:\n%s\n" % (
                        result, expected)
                self.error_continuation(msg)

        return {
            'success': success,
            'time':get_total_seconds(timedelta),
        }
Esempio n. 2
0
    def test(self, dirname, binary, fin, fout):
        self.info("Testing %s ... " % fin, newline=False)
        start = datetime.now()
        cmd = 'cat %s | %s' % (fin, binary)
        runinfo = self.run_test_command(cmd)
        output = runinfo['output']
        returncode = runinfo['returncode']
        timeouted = runinfo['timeouted']

        timedelta = datetime.now() - start

        try:
            expected = open(fout).read().strip()
            fout_read = True
        except IOError:
            expected = '[File could not be read]'
            fout_read = False

        success = output == expected and returncode == 0 and fout_read
        if success:
            self.success_continuation('OK [%.3f]s' % get_total_seconds(timedelta))
        else:
            self.error_continuation('Fail')
            if self.namespace.verbose:
                if timeouted:
                    msg = "    Program timeouted after %.1fs" % self.namespace.timeout
                elif returncode != 0:
                    msg = "    Program returned with code %d:\n%s" % (
                        returncode, output)
                elif not fout_read:
                    msg = "    out file could not be read (%r)" % fout
                else:
                    msg = "    Result was:\n%s\n but expected:\n%s\n" % (
                        output, expected)
                self.error_continuation(msg)

        return {
            'success': success,
            'time': get_total_seconds(timedelta),
        }
Esempio n. 3
0
    def test(self, dirname, binary, fin, fout):
        self.info("Testing %s ... " % fin, newline=False)
        start = datetime.now()
        prog = 'cat %s | %s' % (fin, binary)
        proc = Popen(prog, stdout=PIPE, stderr=PIPE, shell=True)
        out, err = proc.communicate()
        result = out.strip()
        result = result.replace('\r', '')
        timedelta = datetime.now() - start

        prog2 = 'cat %s' % fout
        proc2 = Popen(prog2, stdout=PIPE, stderr=PIPE, shell=True)
        out2, err2 = proc2.communicate()
        expected = out2.strip()

        expected = expected.replace('\r', '')

        success = result == expected and proc.returncode == 0 and proc2.returncode == 0
        if success:
            self.success_continuation('OK [%.3f]s' %
                                      get_total_seconds(timedelta))
        else:
            self.error_continuation('Fail')
            if self.namespace.verbose:
                if proc.returncode != 0:
                    msg = "    Program returned with code %d:\n%s" % (
                        proc.returncode, err)
                else:
                    msg = "    Result was:\n%s\n but expected:\n%s\n" % (
                        result, expected)
                self.error_continuation(msg)

        return {
            'success': success,
            'time': get_total_seconds(timedelta),
        }
Esempio n. 4
0
 def assertTotalSecondsEqual(self, timedelta, expected_seconds):
     result = get_total_seconds(timedelta)
     self.assertEqual(
         result, expected_seconds,
         "We computed %s seconds for %s but expected %s" %
         (result, timedelta, expected_seconds))
Esempio n. 5
0
 def assertTotalSecondsEqual(self, timedelta, expected_seconds):
     result = get_total_seconds(timedelta)
     self.assertEqual(result, expected_seconds,
         "We computed %s seconds for %s but expected %s"
         % (result, timedelta, expected_seconds))