Exemplo n.º 1
0
Arquivo: xv6.py Projeto: ZhengyiC/p3
    def run(self):
        tester_path = self.test_path + "/" + self.tester
        self.log("Running xv6 user progam " + str(tester_path))

        shutil.copy(tester_path, self.project_path + "/user/tester.c")

        if hasattr(self, 'rand_test'):
            shutil.copy(self.test_path + "/ctests/rand.c",
                        self.project_path + "/kernel/rand.c")

        is_success = self.make(["xv6.img", "fs.img"])
        if not is_success:
            return  # stop test on if make fails

        target = "qemu-nox " + self.make_qemu_args
        if self.use_gdb:
            target = "qemu-gdb " + self.make_qemu_args
        self.log("make " + target)
        child = pexpect.spawn("make " + target,
                              cwd=self.project_path,
                              logfile=self.logfd,
                              timeout=None)
        self.children.append(child)

        if self.use_gdb:
            gdb_child = subprocess.Popen(
                ["xterm", "-title", "\"gdb\"", "-e", "gdb"],
                cwd=self.project_path)
            self.children.append(gdb_child)

        child.expect_exact("init: starting sh")
        child.expect_exact("$ ")
        child.sendline("tester")

        # check if test passed
        patterns = [
            "TEST FAILED", "cpu\d: panic: .*\n", "TEST PASSED", "[$][ ]"
        ]
        index = child.expect(patterns)
        if index == 0:
            self.fail("tester failed")
        elif index == 1:
            self.fail("xv6 kernel panic")
        elif index == 3:
            self.fail("tester failed")

        if self.use_gdb:
            child.wait()
        else:
            child.close()
        self.done()
Exemplo n.º 2
0
    def run(self):
        image_path = os.path.join(self.test_path, self.image)
        image_dest = os.path.join(self.project_path, "fs.img")

        is_success = self.make(["xv6.img", "fs.img"])
        if not is_success:
            return  # stop test on if make fails

        self.log("Using image " + str(image_path))
        shutil.copy(image_path, image_dest)
        os.utime(image_dest, None)

        target = "qemu-nox"
        if self.use_gdb:
            target = "qemu-gdb"
        self.log("make " + target)
        child = pexpect.spawn("make " + target,
                              cwd=self.project_path,
                              logfile=self.logfd,
                              timeout=None)
        self.children.put(child.pid)

        if self.use_gdb:
            gdb_child = subprocess.Popen(
                ["xterm", "-title", "\"gdb\"", "-e", "gdb"],
                cwd=self.project_path)
            self.children.put(gdb_child.pid)

        child.expect_exact("init: starting sh")
        child.expect_exact("$ ")
        child.sendline(self.command)

        # check if test passed
        patterns = [
            "TEST FAILED", "cpu\d: panic: .*\n", "TEST PASSED", "[$][ ]"
        ]
        index = child.expect(patterns)
        if index == 0:
            self.fail("tester failed")
        elif index == 1:
            self.fail("xv6 kernel panic")
        elif index == 3:
            self.fail("tester failed")

        if self.use_gdb:
            child.wait()
        else:
            child.close()
        self.done()
Exemplo n.º 3
0
   def run(self):
      image_path = os.path.join(self.test_path, self.image)
      image_dest = os.path.join(self.project_path, "fs.img")

      is_success = self.make(["xv6.img", "fs.img"])
      if not is_success:
         return # stop test on if make fails

      self.log("Using image " + str(image_path))
      shutil.copy(image_path, image_dest)
      os.utime(image_dest, None)

      target = "qemu-nox"
      if self.use_gdb:
         target = "qemu-gdb"
      self.log("make " + target)
      child = pexpect.spawn("make " + target,
            cwd=self.project_path,
            logfile=self.logfd,
            timeout=None)
      self.children.append(child)

      if self.use_gdb:
         gdb_child = subprocess.Popen(
               ["xterm", "-title", "\"gdb\"", "-e", "gdb"],
               cwd=self.project_path)
         self.children.append(gdb_child)

      child.expect_exact("init: starting sh")
      child.expect_exact("$ ")
      child.sendline(self.command)

      # check if test passed
      patterns = ["TEST FAILED", "cpu\d: panic: .*\n", "TEST PASSED", "[$][ ]"]
      index = child.expect(patterns)
      if index == 0:
         self.fail("tester failed")
      elif index == 1:
         self.fail("xv6 kernel panic")
      elif index == 3:
         self.fail("tester failed")

      if self.use_gdb:
         child.wait()
      else:
         child.close()
      self.done()
   def run(self):
      tester_path = self.test_path + "/" + self.tester
      self.log("Running xv6 user progam " + str(tester_path))
      shutil.copy(tester_path, self.project_path + "/user/tester.c")

      is_success = self.make(["xv6.img", "fs.img"])
      if not is_success:
         return # stop test on if make fails

      target = "qemu-nox " + self.make_qemu_args
      if self.use_gdb:
         target = "qemu-gdb " + self.make_qemu_args
      self.log("make " + target)
      child = pexpect.spawn("make " + target,
            cwd=self.project_path,
            logfile=self.logfd,
            timeout=None)
      self.children.put(child.pid)

      if self.use_gdb:
         gdb_child = subprocess.Popen(
               ["xterm", "-title", "\"gdb\"", "-e", "gdb"],
               cwd=self.project_path)
         self.children.put(gdb_child.pid)

      child.expect_exact("init: starting sh")
      child.expect_exact("$ ")
      child.sendline("tester")

      # check if test passed
      patterns = ["TEST FAILED", "cpu\d: panic: .*\n", "TEST PASSED", "[$][ ]"]
      index = child.expect(patterns)
      if index == 0:
         self.fail("tester failed")
      elif index == 1:
         self.fail("xv6 kernel panic")
      elif index == 3:
         self.fail("tester failed")

      if self.use_gdb:
         child.wait()
      else:
         child.close()
      self.done()
Exemplo n.º 5
0
   def run(self):
      before_image = os.path.join(self.test_path, self.before_image)
      actual_image = os.path.join(self.project_path, "fs.img")

      is_success = self.make(["xv6.img", "fs.img"])
      if not is_success:
         return # stop test on if make fails

      self.log("Using image " + str(before_image))
      shutil.copy(before_image, actual_image)
      os.utime(actual_image, None)

      target = "qemu-nox"
      if self.use_gdb:
         target = "qemu-gdb"
      self.log("make " + target)
      child = pexpect.spawn("make " + target,
            cwd=self.project_path,
            logfile=self.logfd,
            timeout=None)
      self.children.append(child)

      if self.use_gdb:
         gdb_child = subprocess.Popen(
               ["xterm", "-title", "\"gdb\"", "-e", "gdb"],
               cwd=self.project_path)
         self.children.append(gdb_child)

      child.expect_exact("init: starting sh")
      child.expect_exact("$ ")
      child.sendline(self.command)

      # check if test passed
      patterns = ["TEST FAILED", "cpu\d: panic: .*\n", "TEST PASSED", "[$][ ]"]
      index = child.expect(patterns)
      if index == 0:
         self.fail("tester failed")
      elif index == 1:
         self.fail("xv6 kernel panic")
      elif index == 3:
         self.fail("tester failed")

      if self.use_gdb:
         child.wait()
      else:
         child.close()

      if self.after_image is not None:
         after_image = os.path.join(self.test_path, self.after_image)
         self.log("Comparing actual image with expected image")
         images = [after_image, actual_image]
         size = max([os.path.getsize(x) for x in images])
         fd = [open(x, "rb") for x in images]
         for i in range((size / 512) + 1):
            block = [x.read(512) for x in fd]
            if block[0] != block[1]:
               # print block[0], block[1]
               self.fail("Block " + str(i) +
                     " of fs.img does not match expected")
               break
            elif len(block[0]) == 0:
               break

         [x.close() for x in fd]

      self.done()
Exemplo n.º 6
0
    def run(self):
        before_image = os.path.join(self.test_path, self.before_image)
        actual_image = os.path.join(self.project_path, "fs.img")

        is_success = self.make(["xv6.img", "fs.img"])
        if not is_success:
            return  # stop test on if make fails

        self.log("Using image " + str(before_image))
        shutil.copy(before_image, actual_image)
        os.utime(actual_image, None)

        target = "qemu-nox"
        if self.use_gdb:
            target = "qemu-gdb"
        self.log("make " + target)
        child = pexpect.spawn("make " + target,
                              cwd=self.project_path,
                              logfile=self.logfd,
                              timeout=None)
        self.children.append(child)

        if self.use_gdb:
            gdb_child = subprocess.Popen(
                ["xterm", "-title", "\"gdb\"", "-e", "gdb"],
                cwd=self.project_path)
            self.children.append(gdb_child)

        child.expect_exact("init: starting sh")
        child.expect_exact("$ ")
        child.sendline(self.command)

        # check if test passed
        patterns = [
            "TEST FAILED", "cpu\d: panic: .*\n", "TEST PASSED", "[$][ ]"
        ]
        index = child.expect(patterns)
        if index == 0:
            self.fail("tester failed")
        elif index == 1:
            self.fail("xv6 kernel panic")
        elif index == 3:
            self.fail("tester failed")

        if self.use_gdb:
            child.wait()
        else:
            child.close()

        if self.after_image is not None:
            after_image = os.path.join(self.test_path, self.after_image)
            self.log("Comparing actual image with expected image")
            images = [after_image, actual_image]
            size = max([os.path.getsize(x) for x in images])
            fd = [open(x, "rb") for x in images]
            for i in range((size / 512) + 1):
                block = [x.read(512) for x in fd]
                if block[0] != block[1]:
                    self.fail("Block " + str(i) +
                              " of fs.img does not match expected")
                    break
                elif len(block[0]) == 0:
                    break

            [x.close() for x in fd]

        self.done()