Esempio n. 1
0
 def postprocess_negative(self, this_result, memory_container, passed):
     if this_result is not None:  # Verify failed
         self.failif(not isinstance(this_result, dict),
                     ("expected this_result to be a dict; it's a %s" %
                      this_result.__class__))
         status = this_result.keys().pop()
         if status is "FAIL":
             self.logdebug("Expected fail: %s", this_result)
             passed.append(True)
         elif status is 'FAIL':
             self.logerror("Unexpected pass: %s", this_result)
             passed.append(False)
         else:
             raise xceptions.DockerTestError("%s invalid result %s" %
                                             this_result)
     else:  # cgroups could not be checked
         cmdresult = memory_container.cmdresult
         exit_status = cmdresult.exit_status
         if exit_status is None:
             self.logerror("Unexpected running container: %s",
                           memory_container)
             passed.append(False)
             return
         # Verify no crashes or oopses
         OutputNotBad(cmdresult)
         # Non-zero exit should produce usage/error message
         if exit_status == 0:
             self.logerror("Unexpected success: %s" % cmdresult)
             passed.append(False)
         else:
             self.logdebug("Expected failure: %s" % cmdresult)
             passed.append(True)
Esempio n. 2
0
 def postprocess_positive(self, this_result, passed):
     if this_result is None:
         raise xceptions.DockerTestError("Invoked with null results")
     self.failif(not isinstance(this_result, dict),
                 ("expected this_result to be a dict; it's a %s" %
                  this_result.__class__))
     status = this_result.keys().pop()
     if status is "PASS":
         self.logdebug(this_result)
         passed.append(True)
     elif status is 'FAIL':
         self.logerror(this_result)
         passed.append(False)
     else:
         raise xceptions.DockerTestError("%s invalid result %s" %
                                         this_result)
Esempio n. 3
0
 def postprocess_positive(self, this_result, passed):
     self.failif(not isinstance(this_result, dict))
     status = this_result.keys().pop()
     if status is "PASS":
         self.logdebug(this_result)
         passed.append(True)
     elif status is 'FAIL':
         self.logerror(this_result)
         passed.append(False)
     else:
         raise xceptions.DockerTestError("%s invalid result %s" %
                                         this_result)
Esempio n. 4
0
    def _check_result(self, test, tty):
        def check_output(exps, notexps, act1, act2, result):
            """
            1. Checks if exps strings are in act1 output and not in act2
            2. Checks if notexps strings are not in act1 (doesn't care of act2)
            """
            act_name = act1
            act1 = getattr(result, act1)
            act2 = getattr(result, act2)
            for exp in exps:
                if not re.findall(exp, act1):
                    self.logerror("%sExpr '%s' not in %s:\n%s", prefix, exp,
                                  act_name, result)
                    return 1
                elif re.findall(exp, act2):
                    self.logerror(
                        "%sExpr '%s' was expected in %s and is also"
                        "in the other out:\n%s", prefix, exp, act_name, result)
                    return 1
            for notexp in notexps:
                if re.findall(notexp, act1):
                    self.logerror("%sString '%s' present in %s:\n%s", prefix,
                                  notexp, act_name, result)
                    return 1
            return 0

        # check exit status
        prefix = 'test %s, tty %s: ' % (test, tty)
        exp = self.sub_stuff['exp_%s_exit_%s' % (test, tty)]
        try:
            dkrcmd = self.sub_stuff['res_%s_%s' % (test, tty)]
            act = dkrcmd.exit_status
        except AttributeError:
            raise xceptions.DockerTestError("Command was not executed: %s" %
                                            dkrcmd)
        if exp != act:
            self.logerror("%sExit status of:\n%s\nis not %s", prefix,
                          self.sub_stuff['res_%s_%s' % (test, tty)], exp)
            return 1
        # check stdout
        if check_output(self.sub_stuff.get('exp_%s_%s' % (test, tty), []),
                        self.sub_stuff.get('exp_%s_not_%s' % (test, tty),
                                           []), 'stdout', 'stderr',
                        self.sub_stuff['res_%s_%s' % (test, tty)]):
            return 1
        # check stderr
        if check_output(
                self.sub_stuff.get('exp_%s_err_%s' % (test, tty), []),
                self.sub_stuff.get('exp_%s_err_not_%s' % (test, tty), []),
                'stderr', 'stdout', self.sub_stuff['res_%s_%s' % (test, tty)]):
            return 1
        return 0
Esempio n. 5
0
 def postprocess(self):
     super(cpu_base, self).postprocess()
     result = self.sub_stuff['result']
     invalid = xceptions.DockerTestError("Invalid result %s" % result)
     if self.config['expect_success'] == "PASS":
         if result['FAIL'] is not None:
             raise xceptions.DockerTestFail(result)
         elif result['PASS'] is not None:
             self.logdebug(result)
         else:
             raise invalid
     else:
         self.loginfo("Command expected to fail!")
         if result['PASS'] is not None:
             raise xceptions.DockerTestFail(result)
         elif result['FAIL'] is not None:
             self.logdebug(result)
         else:
             raise invalid