def test_pylint_file(self): try: run_shell_cmd( r"find . -iname \"*\.py\" -type f -print0 | PYTHONPATH=${PYTHONPATH}:. xargs -r -0 -n1 pylint --load-plugins pylint_django -E --reports=n 2>&1", cwd=config.TESTDIR + "/bitbake/lib/toaster") except ShellCmdException as exc: self.fail("Pylint fails: %s\n" % exc)
def setUp(self): self.origdir = os.getcwd() self.crtdir = os.path.dirname(config.TESTDIR) self.cleanup_database = False os.chdir(self.crtdir) if not os.path.exists(os.path.join(self.crtdir, "toaster.sqlite")): self.cleanup_database = True run_shell_cmd("%s/bitbake/lib/toaster/manage.py syncdb --noinput" % config.TESTDIR) run_shell_cmd("%s/bitbake/lib/toaster/manage.py migrate orm" % config.TESTDIR) run_shell_cmd("%s/bitbake/lib/toaster/manage.py migrate bldcontrol" % config.TESTDIR) run_shell_cmd( "%s/bitbake/lib/toaster/manage.py loadconf %s/meta-yocto/conf/toasterconf.json" % (config.TESTDIR, config.TESTDIR) ) run_shell_cmd("%s/bitbake/lib/toaster/manage.py lsupdates" % config.TESTDIR) setup = pexpect.spawn("%s/bitbake/lib/toaster/manage.py checksettings" % config.TESTDIR) setup.logfile = sys.stdout setup.expect(r".*or type the full path to a different directory: ") setup.sendline("") setup.sendline("") setup.expect(r".*or type the full path to a different directory: ") setup.sendline("") setup.expect(r"Enter your option: ") setup.sendline("0") self.child = pexpect.spawn( "bash", ["%s/bitbake/bin/toaster" % config.TESTDIR, "webport=%d" % config.TOASTER_PORT, "nobrowser"], cwd=self.crtdir, ) self.child.logfile = sys.stdout self.child.expect("Toaster is now running. You can stop it with Ctrl-C")
def test_compile_file(self): try: run_shell_cmd( "find . -name *py -type f -print0 | xargs -0 -n1 -P20 python -m py_compile", config.TESTDIR) except ShellCmdException as exc: self.fail("Error compiling python files: %s" % (exc))
def main(): (options, args) = validate_args() settings = read_settings() need_cleanup = False # dump debug info dump_info(settings, options, args) testdir = None no_failures = 1 try: if options.testdir is not None and os.path.exists(options.testdir): testdir = os.path.abspath(options.testdir) config.logger.info("No checkout, using %s", testdir) else: need_cleanup = True testdir = set_up_test_branch(settings, args[0]) # we expect a branch name as first argument config.TESTDIR = testdir # we let tests know where to run # ensure that the test dir only contains no *.pyc leftovers run_shell_cmd("find '%s' -type f -name *.pyc -exec rm {} \\;" % testdir) no_failures = execute_tests(testdir, options.singletest) except ShellCmdException as exc: import traceback config.logger.error("Error while setting up testing. Traceback: \n%s", traceback.format_exc(exc)) finally: if need_cleanup and testdir is not None: clean_up(testdir) sys.exit(no_failures)
def main(): (options, args) = validate_args() settings = read_settings() need_cleanup = False # dump debug info dump_info(settings, options, args) testdir = None no_failures = 1 try: if options.testdir is not None and os.path.exists(options.testdir): testdir = os.path.abspath(options.testdir) config.logger.info("No checkout, using %s", testdir) else: need_cleanup = True testdir = set_up_test_branch(settings, args[0]) # we expect a branch name as first argument config.TESTDIR = testdir # we let tests know where to run # ensure that the test dir only contains no *.pyc leftovers run_shell_cmd("find '%s' -type f -name *.pyc -exec rm {} \\;" % testdir) no_failures = execute_tests(testdir, options.singletest) except ShellCmdException as exc: import traceback config.logger.error("Error while setting up testing. Traceback: \n%s", traceback.format_exc()) finally: if need_cleanup and testdir is not None: clean_up(testdir) sys.exit(no_failures)
def test_start_interactive_mode(self): try: run_shell_cmd( "bash -c 'source %s/oe-init-build-env && source toaster start webport=%d && source toaster stop'" % (config.TESTDIR, config.TOASTER_PORT), config.TESTDIR) except ShellCmdException as exc: self.fail("Failed starting interactive mode: %s" % (exc))
def test_pylint_file(self): try: run_shell_cmd( r"find . -iname \"*\.py\" -type f -print0 | PYTHONPATH=${PYTHONPATH}:. xargs -r -0 -n1 pylint --load-plugins pylint_django -E --reports=n 2>&1", cwd=config.TESTDIR + "/bitbake/lib/toaster", ) except ShellCmdException as exc: self.fail("Pylint fails: %s\n" % exc)
def test_start_managed_mode(self): try: run_shell_cmd( "%s/bitbake/bin/toaster webport=%d nobrowser & sleep 10 && curl http://localhost:%d/ && kill -2 %%1" % (config.TESTDIR, config.TOASTER_PORT, config.TOASTER_PORT), config.TESTDIR) except ShellCmdException as exc: self.fail("Failed starting managed mode: %s" % (exc))
def test_start_managed_mode(self): try: run_shell_cmd( "%s/bitbake/bin/toaster webport=%d nobrowser & sleep 10 && curl http://localhost:%d/ && kill -2 %%1" % (config.TESTDIR, config.TOASTER_PORT, config.TOASTER_PORT), config.TESTDIR, ) except ShellCmdException as exc: self.fail("Failed starting managed mode: %s" % (exc))
def test_start_interactive_mode(self): try: run_shell_cmd( "bash -c 'source %s/oe-init-build-env && source toaster start webport=%d && source toaster stop'" % (config.TESTDIR, config.TOASTER_PORT), config.TESTDIR, ) except ShellCmdException as exc: self.fail("Failed starting interactive mode: %s" % (exc))
def set_up_test_branch(settings, branch_name): testdir = "%s/%s.%d" % (settings['workdir'], config.TEST_DIR_NAME, config.OWN_PID) # creates the host dir if os.path.exists(testdir): raise Exception("Test dir '%s'is already there, aborting" % testdir) # may raise OSError, is to be handled by the caller os.makedirs(testdir) # copies over the .git from the localclone run_shell_cmd("cp -a '%s'/.git '%s'" % (settings['localclone'], testdir)) # add the remote if it doesn't exist crt_remotes = run_shell_cmd("git remote -v", cwd=testdir) remotes = [word for line in crt_remotes.split("\n") for word in line.split()] if not config.CONTRIB_REPO in remotes: remote_name = "tts_contrib" run_shell_cmd("git remote add %s %s" % (remote_name, config.CONTRIB_REPO), cwd=testdir) else: remote_name = remotes[remotes.index(config.CONTRIB_REPO) - 1] # do the fetch run_shell_cmd("git fetch %s -p" % remote_name, cwd=testdir) # do the checkout run_shell_cmd("git checkout origin/master && git branch -D %s; git checkout %s/%s -b %s && git reset --hard" % (branch_name, remote_name, branch_name, branch_name), cwd=testdir) return testdir
def set_up_test_branch(settings, branch_name): testdir = "%s/%s.%d" % (settings['workdir'], config.TEST_DIR_NAME, config.OWN_PID) # creates the host dir if os.path.exists(testdir): raise Exception("Test dir '%s'is already there, aborting" % testdir) # may raise OSError, is to be handled by the caller os.makedirs(testdir) # copies over the .git from the localclone run_shell_cmd("cp -a '%s'/.git '%s'" % (settings['localclone'], testdir)) # add the remote if it doesn't exist crt_remotes = run_shell_cmd("git remote -v", cwd=testdir) remotes = [word for line in crt_remotes.split("\n") for word in line.split()] if not config.CONTRIB_REPO in remotes: remote_name = "tts_contrib" run_shell_cmd("git remote add %s %s" % (remote_name, config.CONTRIB_REPO), cwd=testdir) else: remote_name = remotes[remotes.index(config.CONTRIB_REPO) - 1] # do the fetch run_shell_cmd("git fetch %s -p" % remote_name, cwd=testdir) # do the checkout run_shell_cmd("git checkout origin/master && git branch -D %s; git checkout %s/%s -b %s && git reset --hard" % (branch_name, remote_name, branch_name, branch_name), cwd=testdir) return testdir
def main(): # we don't do anything if we have another instance of us running lock_file = _take_lockfile() if lock_file is None: if config.DEBUG: print("Concurrent script in progress, exiting") sys.exit(1) next_task = read_next_task_by_state(config.TASKS.PENDING) if next_task is not None: print("Next task is", next_task) errtext = None out = None try: out = shellutils.run_shell_cmd("%s %s" % (os.path.join( os.path.dirname(__file__), "runner.py"), next_task)) except ShellCmdException as exc: print("Failed while running the test runner: %s", exc) errtext = exc.__str__() send_report(next_task, out, errtext) read_next_task_by_state(config.TASKS.INPROGRESS, next_task) else: print("No task") shellutils.unlockfile(lock_file)
def main(): # we don't do anything if we have another instance of us running lock_file = _take_lockfile() if lock_file is None: if config.DEBUG: print("Concurrent script in progress, exiting") sys.exit(1) next_task = read_next_task_by_state(config.TASKS.PENDING) if next_task is not None: print("Next task is", next_task) errtext = None out = None try: out = shellutils.run_shell_cmd("%s %s" % (os.path.join(os.path.dirname(__file__), "runner.py"), next_task)) except ShellCmdException as exc: print("Failed while running the test runner: %s", exc) errtext = exc.__str__() send_report(next_task, out, errtext) read_next_task_by_state(config.TASKS.INPROGRESS, next_task) else: print("No task") shellutils.unlockfile(lock_file)
def setUp(self): self.origdir = os.getcwd() self.crtdir = os.path.dirname(config.TESTDIR) self.cleanup_database = False os.chdir(self.crtdir) if not os.path.exists(os.path.join(self.crtdir, "toaster.sqlite")): self.cleanup_database = True run_shell_cmd("%s/bitbake/lib/toaster/manage.py syncdb --noinput" % config.TESTDIR) run_shell_cmd("%s/bitbake/lib/toaster/manage.py migrate orm" % config.TESTDIR) run_shell_cmd( "%s/bitbake/lib/toaster/manage.py migrate bldcontrol" % config.TESTDIR) run_shell_cmd( "%s/bitbake/lib/toaster/manage.py loadconf %s/meta-yocto/conf/toasterconf.json" % (config.TESTDIR, config.TESTDIR)) run_shell_cmd("%s/bitbake/lib/toaster/manage.py lsupdates" % config.TESTDIR) setup = pexpect.spawn( "%s/bitbake/lib/toaster/manage.py checksettings" % config.TESTDIR) setup.logfile = sys.stdout setup.expect(r".*or type the full path to a different directory: ") setup.sendline('') setup.sendline('') setup.expect(r".*or type the full path to a different directory: ") setup.sendline('') setup.expect(r"Enter your option: ") setup.sendline('0') self.child = pexpect.spawn("bash", [ "%s/bitbake/bin/toaster" % config.TESTDIR, "webport=%d" % config.TOASTER_PORT, "nobrowser" ], cwd=self.crtdir) self.child.logfile = sys.stdout self.child.expect( "Toaster is now running. You can stop it with Ctrl-C")
s = smtplib.SMTP("localhost") s.sendmail(config.OWN_EMAIL_ADDRESS, [config.REPORT_EMAIL_ADDRESS], msg.as_string()) s.quit() if __name__ == "__main__": # we don't do anything if we have another instance of us running lf = _take_lockfile() if lf is None: if DEBUG: print("Concurrent script in progress, exiting") sys.exit(1) next_task = read_next_task_by_state(config.TASKS.PENDING) if next_task is not None: print("Next task is", next_task) errtext = None out = None try: out = shellutils.run_shell_cmd("%s %s" % (os.path.join(os.path.dirname(__file__), "runner.py"), next_task)) pass except ShellCmdException as e: print("Failed while running the test runner: %s", e) errtext = e.__str__() send_report(next_task, out, errtext) read_next_task_by_state(config.TASKS.INPROGRESS, next_task) else: print("No task") shellutils.unlockfile(lf)
def test_compile_file(self): try: run_shell_cmd("find . -name *py -type f -print0 | xargs -0 -n1 -P20 python -m py_compile", config.TESTDIR) except ShellCmdException as exc: self.fail("Error compiling python files: %s" % (exc))
def clean_up(testdir): run_shell_cmd("rm -rf -- '%s'" % testdir)
s = smtplib.SMTP("localhost") s.sendmail(config.OWN_EMAIL_ADDRESS, [config.REPORT_EMAIL_ADDRESS], msg.as_string()) s.quit() if __name__ == "__main__": # we don't do anything if we have another instance of us running lf = _take_lockfile() if lf is None: if DEBUG: print("Concurrent script in progress, exiting") sys.exit(1) next_task = read_next_task_by_state(config.TASKS.PENDING) if next_task is not None: print("Next task is", next_task) errtext = None out = None try: out = shellutils.run_shell_cmd("./runner.py %s" % next_task) pass except ShellCmdException as e: print("Failed while running the test runner: %s", e) errtext = e.__str__() send_report(next_task, out, errtext) read_next_task_by_state(config.TASKS.INPROGRESS, next_task) else: print("No task") shellutils.unlockfile(lf)
def setUp(self): run_shell_cmd("bash -c 'rm -f build/*log'")
def clean_up(testdir): run_shell_cmd("rm -rf -- '%s'" % testdir)
def setUp(self): run_shell_cmd("bash -c 'rm -f build/*log'")