Exemplo n.º 1
0
    def test_broker_file_upload__bad_params(self):
        sp = commonl.subpython(
            self.srcdir +
            "/tcf --config-path : -vvv --url %s store-upload"
            % (self.url))
        r = sp.join()
        self.assertNotEqual(
            r, 0,
            msg = sp.output_str + type(self).ttbd_info())

        sp = commonl.subpython(
            self.srcdir +
            "/tcf --config-path : -vvv --url %s store-upload %s"
            % (self.url, self.target_names[0]))
        r = sp.join()
        self.assertNotEqual(
            r, 0,
            msg = sp.output_str + type(self).ttbd_info())

        sp = commonl.subpython(
            self.srcdir +
            "/tcf --config-path : -vvv --url %s store-upload %s /dest/path/file"
            % (self.url, self.target_names[0]))
        r = sp.join()
        self.assertNotEqual(
            r, 0,
            msg = sp.output_str + type(self).ttbd_info())
Exemplo n.º 2
0
    def test_config_file_target_list(self):
        """
        Access the URL by configuration
        """
        config = tempfile.NamedTemporaryFile(
            prefix = commonl.testing.mkprefix("tcf-config", cls = type(self)),
            suffix = ".py", delete = True)
        config.write("""\
tcfl.config.url_add("%s")
""" \
                     % self.url)
        config.flush()
        config.seek(0)
        sp = commonl.subpython(
            self.srcdir +
            "/tcf --config-path : -vvv --config-path '' --config-file %s list"
            % config.name)
        r = sp.join()
        self.assertEqual(
            r, 0,
            msg = sp.output_str \
            + "tcf-config: ".join(["\n"] + config.readlines()) \
            + type(self).ttbd_info())

        for target_name in self.target_names:
            self.assertRegex(
                "".join(sp.stdout_lines), re.compile(target_name),
                msg = "exit: target_name '%s' not found\n" % target_name \
                + sp.output_str \
                + "tcf-config: ".join(["\n"] + config.readlines()) \
                + type(self).ttbd_info())
Exemplo n.º 3
0
    def test_target_release(self):
        sp = commonl.subpython(
            self.srcdir + "/tcf --config-path : -vvv --url %s acquire %s" \
            % (self.url, self.target_names[0]))
        r = sp.join()
        self.assertEqual(
            r, 0,
            msg = sp.output_str + type(self).ttbd_info())

        sp = commonl.subpython(
            self.srcdir + "/tcf --config-path : -vvv --url %s release %s" \
            % (self.url, self.target_names[0]))
        r = sp.join()
        self.assertEqual(
            r, 0,
            msg = sp.output_str + type(self).ttbd_info())
Exemplo n.º 4
0
 def test_02_power_on(self):
     sp = commonl.subpython(
         self.srcdir + "/tcf --config-path : --url http://localhost:%d "
         "power-on %s"\
         % (self.port, self.target))
     self.assertEqual(sp.join(), 0, msg = sp.output_str)
     logi("letting it run three seconds")
     time.sleep(3)
Exemplo n.º 5
0
    def test_config_bad_url(self):
        """
        Access the URL by configuration
        """

        sp = commonl.subpython(
            self.srcdir
            + "/tcf --config-path : -vvv --url 'bad/.url_343flimy' list")
        r = sp.join()
        self.assertNotEqual(r, 0, msg = sp.output_str)
Exemplo n.º 6
0
 def test_01_images_flash(self):
     kernel = commonl.testing.test_ttbd_mixin.srcdir + "/tests/data/philosophers-uk-generic_pc.elf"
     image = os.path.basename(kernel)
     shutil.copy(kernel, self.wd)
     # FIXME copy file
     sp = commonl.subpython(
         self.srcdir + "/tcf --config-path : --url http://localhost:%d "
         "images-flash %s kernel:%s"
         % (self.port, self.target, image))
     self.assertEqual(sp.join(), 0, msg = sp.output_str)
Exemplo n.º 7
0
 def test_target_acquire_nonexistant(self):
     sp = commonl.subpython(
         self.srcdir +
         "/tcf --config-path : -vvv --url %s acquire non_existant"
         % self.url)
     sp.join()
     self.assertRegex(
         sp.output_str,
         "IndexError: target-id 'non_existant': not found$",
         msg = "IndexError not raised by tcf\n" \
         + sp.output_str + type(self).ttbd_info())
Exemplo n.º 8
0
 def test_target_list(self):
     sp = commonl.subpython(
         self.srcdir + "/tcf --config-path : -vvv --url %s list" % self.url)
     r = sp.join()
     self.assertEqual(
         r, 0,
         msg = sp.output_str + type(self).ttbd_info())
     for target_name in self.target_names:
         self.assertRegex(
             "".join(sp.stdout_lines), re.compile(target_name),
             msg = "exit: target_name '%s' not found\n" % target_name \
             + sp.output_str + type(self).ttbd_info())
Exemplo n.º 9
0
    def test_broker_file_upload__simple(self):
        filename = self.ttbd_config.name
        sp = commonl.subpython(
            self.srcdir +
            "/tcf --config-path : -vvv --url %s store-upload %s  dest/file %s"
            % (self.url, self.target_names[0], filename))
        r = sp.join()
        self.assertEqual(
            r, 0,
            msg = sp.output_str + type(self).ttbd_info())
        # Check the file made it to the daemon's file storage (it's in
        # localhost, so we know it is there)
        expected_filename = os.path.normpath("%s/local/dest/file" % (
            self.ttbd_files_dir))
        logging.debug("expected_filename %s", expected_filename)
        if not os.path.isfile(expected_filename):
            self.fail("expected file '%s' not found\n" % expected_filename \
                      + sp.output_str + type(self).ttbd_info())
        if not filecmp.cmp(expected_filename, filename):
            self.fail("uploaded file and original file are different")

        # Check we can list it and it matches the hash
        sp = commonl.subpython(
            self.srcdir + "/tcf --config-path : --url %s store-list %s" \
            % (self.url, self.target_names[0]))
        r = sp.join()
        self.assertEqual(
            r, 0,
            msg = sp.output_str + type(self).ttbd_info())
        for line in sp.stdout_lines:
            listed_filename, hexdigest = line.split(" ", 1)
            if '/dest/file' ==  listed_filename:
                self.assertEqual(
                    hexdigest,
                    commonl.hash_file(hashlib.sha256(),
                                      self.ttbd_config.name).hexdigest())
Exemplo n.º 10
0
 def test_03_console_read_all(self):
     sp = commonl.subpython(
         self.srcdir + "/tcf --config-path : --url http://localhost:%d "
         "console-read --all --filter-ansi %s"\
         % (self.port, self.target))
     self.assertEqual(sp.join(), 0, msg = sp.output_str)
     regex = re.compile("^Philosopher [0-9] (EATING|THINKING)")
     count = 0
     for _line in sp.stdout_lines:
         for line in _line.split("\n"):
             line = line.strip()
             m = regex.match(line)
             if m:
                 count += 1
     self.assertGreater(count, 3, msg = "not enough matches found")
Exemplo n.º 11
0
    def test_config_file_bad_url(self):
        """
        Access the URL by configuration
        """
        config = tempfile.NamedTemporaryFile(
            prefix = commonl.testing.mkprefix("tcf-config", cls = type(self)),
            suffix = ".py", delete = True)
        config.write("""\
tcfl.config.url_add("bad/.url_343flimy")
""")
        config.flush()
        config.seek(0)
        sp = commonl.subpython(
            self.srcdir +
            "/tcf --config-path : -vvv --config-path '' --config-file %s list"
            % config.name)
        r = sp.join()
        self.assertEqual(
            r, 1,
            msg = sp.output_str \
            + "tcf-config: ".join(["\n"] + config.readlines()) \
            + type(self).ttbd_info())
Exemplo n.º 12
0
 def test_no_command(self):
     sp = commonl.subpython(self.srcdir + "/tcf")
     r = sp.join()
     self.assertNotEqual(r, 0, msg = sp.output_str)
Exemplo n.º 13
0
 def test_00_acquire(self):
     sp = commonl.subpython(
         self.srcdir + "/tcf -vvv --config-path : --url http://localhost:%d "
         "acquire %s"
         % (self.port, self.target))
     self.assertEqual(sp.join(), 0, msg = sp.output_str)
Exemplo n.º 14
0
 def test_05_store_delete(self):
     sp = commonl.subpython(
         self.srcdir + "/tcf --config-path : --url http://localhost:%d "
         "store-delete %s %s"\
         % (self.port, self.image))
     self.assertEqual(sp.join(), 0, msg = sp.output_str)
Exemplo n.º 15
0
 def test_04_power_off(self):
     sp = commonl.subpython(
         self.srcdir + "/tcf --config-path : --url http://localhost:%d "
         "power-off %s"\
         % (self.port, self.target))
     self.assertEqual(sp.join(), 0, msg = sp.output_str)