Beispiel #1
0
def L_SecureStorage_0011(target, legato):
    """Purpose: Verify that the Secure Storage Write and Read APIs.

    Can be repeatedly called many times reliably.

    This script will
        1. Use the "Write" API to write an item.
        2. Use the "Read" API to read the item.
        3. Repeat 1 and 2 many times.
        4. Verify that for all operations both write and read are
           successful and the data read is the same as the data written.

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param app_leg: fixture regarding to build, install and remove app
    """
    swilog.step("Execute L_SecureStorage_0011")
    test_title = r"Write\ Read\ Test"
    test_type = "writeread"
    test_cycle = "50"

    if not legato.is_app_running(APP_NAME):
        legato.start(APP_NAME)

    secure_storage_test_post(target, legato, test_title, test_type, test_cycle)

    swilog.info("[PASSED] L_SecureStorage_0011")
Beispiel #2
0
def test_setup_teardown_failures():
    """Test failures in setup and teardown.

    Used for checking if this function got called or not.
    """
    swilog.step("Inside test_setup_teardown_failures function")
    assert 0, "Failure in testing phase."
def L_SampleApps_Gpio_0001(legato):
    """Validate that the sample app gpioCf3Demo works well.

    and validate LE-10420.

    This script will
        1. Make and install the test app
        2. Run the test app
        3. Check if expected messages appears in log

    :param legato: fixture to call useful functions regarding legato
    :param init_gpio: fixture to set, check and restore GPIO.
    :param app_leg: fixture to make, install and remove application
    """
    time.sleep(5)
    swilog.step("Execute L_SampleApps_Gpio_0001")
    # Check to see if app started
    check_log(legato, "Starting process 'gpioCf3Demo'")

    # Check to see if GPIO 21 is assigned
    check_log(legato, "Assigning GPIO 21")

    # Check to see if GPIO 22 is assigned
    check_log(legato, "Assigning GPIO 22")

    # Check to see if GPIO 21 is released
    check_log(legato, "Releasing GPIO 21")

    # Check to see if GPIO 22 is released
    check_log(legato, "Releasing GPIO 22")

    # Check to see if Application 'gpioCf3Demo' has stopped.
    check_log(legato, "Application 'gpioCf3Demo' has stopped.")
    swilog.info("[PASSED] L_SampleApps_Gpio_0001")
Beispiel #4
0
def test_one_target(target):
    """Test sending external commands to one target.

    Fill target.xml first.
    """
    swilog.step("Get legato version on first target")
    target.run("ls")
    target.run("legato version")
Beispiel #5
0
def L_UpdateCtrl_Defer_0006(target, legato):
    """Verify that the deferral will be released after.

    stopping the client (process) who called le_updateCtrl_Defer()

    Testing Procedures:
        1. Install the app that invokes le_updateCtrl_Defer()
           onto the target device
        2. Run the app
        3. Stop the app
        4. Install the helloWorld app
        5. Check 4. is successful

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param install_and_clean_app: fixture to clean up environment and build app
    """
    swilog.step("Test L_UpdateCtrl_Defer_0006")
    # Begin of the this TC

    # Set the parameter of the testUpdateCtrl app to
    # "defer" "4" to run this test case
    target.run(
        "config set apps/%s/procs/%s/args/1 defer" % (UPDATE_CTRL_APP, UPDATE_CTRL_APP)
    )
    target.run(
        "config set apps/%s/procs/%s/args/2 6" % (UPDATE_CTRL_APP, UPDATE_CTRL_APP)
    )

    # Run the testUpdateCtrl app that will invoke le_updateCtrl_Defer()
    status, rsp = target.run("app start %s" % UPDATE_CTRL_APP, withexitstatus=True)
    swilog.debug(rsp)
    assert status == 0, "[FAILED] App could not be started."

    # Stop the testUPdateCtrl app which is holding a defer lock
    status, rsp = target.run("app stop %s" % UPDATE_CTRL_APP, withexitstatus=True)
    swilog.debug(rsp)
    assert status == 0, "[FAILED] App could not be stopped."

    # Clean environment
    legato.clean(UPDATE_CTRL_APP, remove_app=False)

    # Check whether defer lock is released so that
    #    any system update is allowed by installing
    # The helloWorld app when when the client (process)
    #    who called le_updateCtrl_Defer() is stopped
    legato.make_install(UPDATE_CTRL_APP, UPDATE_CTRL_PATH)

    # If the target device is not shutting down then,
    # killing the process who holds the defer lock
    # Won't cause reboot. Marked this test case failed
    swilog.info(
        "[PASSED] defer lock was released after a"
        " process which called Defer() is stopped"
    )

    swilog.info("[PASSED] Test L_UpdateCtrl_Defer_0006")
Beispiel #6
0
def L_UpdateCtrl_Defer_0002(target, legato):
    """Verify that le_updateCtrl_Defer() prevents all updates.

    (install an app)

    Initial Condition:
        1. Current system index is "N"

    Test Procedures:
        1. Install the app that invokes le_updateCtrl_Defer()
        onto the target device
        2. Check the current system index is "N + 1"and run the app
        3. Install an app (e.g. helloWorld) onto the target device
        4. Check "Updates are currently deferred" is shown from log
        5. Check the app is not installed on the target device
        (verified by the command line "app list")
        6. Check the current system index is "N + 1"

    (Notes: the current system index, the current system state and
    the current system status can be verified by
    the command line "legato status")

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param install_and_clean_app: fixture to clean up environment and build app
    """
    swilog.step("Test L_UpdateCtrl_Defer_0002")

    # Set the parameter of the testUpdateCtrl app to
    # "defer" "2" to run this test case
    target.run(
        "config set apps/%s/procs/%s/args/1 defer" % (UPDATE_CTRL_APP, UPDATE_CTRL_APP)
    )
    target.run(
        "config set apps/%s/procs/%s/args/2 2" % (UPDATE_CTRL_APP, UPDATE_CTRL_APP)
    )

    # Run the testUpdateCtrl app that will invoke le_updateCtrl_Defer()
    status, rsp = target.run("app start %s" % UPDATE_CTRL_APP, withexitstatus=True)
    swilog.debug(rsp)
    assert status == 0, "[FAILED] App could not be started."

    # Perform an update to the system by installing the new helloWorld app
    # If the installation was successful then,
    # the system update attempt is proceed
    legato.make(HELLO_WORLD_APP, HELLO_WORLD_PATH)
    legato.install(HELLO_WORLD_APP, HELLO_WORLD_PATH, should_fail=True)

    # If the system update was successful,
    # the update was allowed and mark this TC failed
    swilog.info(
        "[PASSED] Defer() doesn't allow update to \
                happen when attempting to install an app"
    )

    swilog.info("[PASSED] Test L_UpdateCtrl_Defer_0002")
Beispiel #7
0
def test_swilog_call():
    """Activate the debug level to see all the messages.

    Usage::

    "letp run --dbg-lvl 0 test/host/scenario/test_swilog.py"
    """
    swilog.debug("debug message")
    swilog.info("info message")
    # to highlight a particular step in the test
    swilog.step("step message")
    swilog.warning("warning message")
    swilog.error("error message")
    swilog.critical("critical message")
Beispiel #8
0
def L_ADEF_0004(legato, init_cleanup_app_version):
    """Test append version in application definition files.

    Args:
        legato: fixture to call useful functions regarding legato
        init_cleanup_app_version: fixture to initial and cleanup the test
    """
    version_append = init_cleanup_app_version["version_append"]
    extra = "no" if version_append == "" else ""

    swilog.step("Test %s appended" % extra)

    version_to_check = ("%s" % VERSION if version_append == "" else "%s.%s" %
                        (VERSION, version_append))

    legato.verify_app_version(APP_NAME, APP_NAME + " " + version_to_check)
Beispiel #9
0
def L_SecureStorage_0004(legato):
    """Multiple apps have independent access to the secured storage.

    Verification:
        This test case will mark as "failed" when
            1. both apps can't read its independent written contents

    This script will
        1. In one Legato app, use the "write" API of the secure storage
           component to write data to the secured storage, with a particular
           storage item name.
        2. In a different Legato app, use the "write" API and the same storage
           item name as step 1, write different data from step 1 to the
           secured storage.
        3. Verify that the data in the two different apps are independently
           stored, by using the "read" API in both apps, and check that the
           data read are as per the originally written data in steps 1 and 2.

    :param legato: fixture to call useful functions regarding legato
    :param test_app: fixture regarding to build, install and remove app
    """
    swilog.step("Execute L_SecureStorage_0004")
    legato.clear_target_log()

    legato.runProc("%s" % TEST_APP_A, "--exe=%s" % TEST_APP_A, "write")
    legato.runProc("%s" % TEST_APP_B, "--exe=%s" % TEST_APP_B, "write")
    legato.runProc("%s" % TEST_APP_A, "--exe=%s" % TEST_APP_A, "read")
    legato.runProc("%s" % TEST_APP_B, "--exe=%s" % TEST_APP_B, "read")

    time.sleep(10)
    rsp1 = legato.find_in_target_log(
        "appA successfully read" " its own written content"
    )
    rsp2 = legato.find_in_target_log(
        "appB successfully read" " its own written content"
    )
    if not rsp1:
        swilog.error("%s doesn't read what it wrote" % TEST_APP_A)
    if not rsp2:
        swilog.error("%s doesn't read what it wrote" % TEST_APP_B)

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
    else:
        swilog.info("[PASSED] L_SecureStorage_0004")
def L_SampleApps_HelloWorld_0002(legato):
    """Script will.

        1. Make and install the test app
        2. Run the test app
        3. Check if expected messages appears in log

    :param legato: fixture to call useful functions regarding legato
    :param app_leg: fixture to make, install and remove application
    """
    text_log = "Hello, world."
    swilog.step("Execute L_SampleApps_ HelloWorld_0002")

    error_msg = "[FAILED] Could not find '%s'" % text_log
    assert legato.find_in_target_log(text_log), error_msg

    swilog.info("[PASSED] L_SampleApps_ HelloWorld_0002")
Beispiel #11
0
def extreme_test(target, flag):
    """Check the 'extreme' flag.

    :param target: fixture to communicate with the target
    :param flag: fixture to provide flag
    """
    stdout = target.run(
        "cd %s/bin/; ./%s -mc 2 %s permissions %s/testFile1" %
        (APP_SANDBOX_PATH, APP_NAME, flag, APP_SANDBOX_PATH),
        check=False,
    )
    swilog.step(stdout)
    error_msg = "[FAILED] Did not find response for extreme flag (%s)" % flag
    assert ("the owner can read, group members can read, and others can "
            "read!!!!!!! 8^O" in stdout), error_msg
    swilog.info("[PASSED] Successfully found response for extreme flag (%s)" %
                flag)
Beispiel #12
0
def banner(request):
    """Print Test banner."""
    test_name = request.node.name
    begin_msg = "========== Begin of %s ==========" % test_name
    equal_nb = 2 * 21
    line = "=" * (equal_nb + len(begin_msg))
    swilog.info(line)
    swilog.info(line)
    swilog.step(begin_msg)
    swilog.info(line)
    swilog.info(line)
    yield
    end_msg = "========== End of %s ==========" % test_name
    line = "=" * (equal_nb + len(end_msg))
    swilog.info(line)
    swilog.info(line)
    swilog.step(end_msg)
    swilog.info(line)
    swilog.info(line)
Beispiel #13
0
def target(request, read_config):
    """Assert target is in desired state before running testcase."""
    swilog.step("####### Check initial target state #######")

    target = None

    try:
        swilog.debug("Construct an on-target obj")
        target = modules.define_target(request, read_config)
    except:
        traceback.print_exc()
        raise

    # Eventually retry, unprotected this time
    if not target:
        target = modules.define_target(request, read_config)

    swilog.step("####### End: Check initial target state #######")
    yield target
    target.teardown()
Beispiel #14
0
def L_Tools_Kmod_0007(target, legato, create_temp_workspace):
    """Verify kmod cmd should not be able to unload kernel module.

        1. Create an update package with a dependence to
        an other module (load:auto) and update the target with it
        2. Verify loading of both modules
        3. Try to unload the required module: it must fail
        4. Try to unload the primary module: it must fail
        5. Compile the default package and update the target with it

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param create_temp_workspace: fixture to create a temporary folder
    """
    # Initialisation:
    # Verify existence of environment variables and files needed.
    # Prepare compilation
    test_name = "L_Tools_Kmod_0007"
    test_passed = True
    # Compile and update target
    swilog.step("Step 1: Compiling...")
    install_system(target, legato, create_temp_workspace, test_name)

    swilog.step("Step 2: Verify mods have been loaded...")
    check_presence_0004 = check_presence(legato, "L_Tools_Kmod_0004")
    check_presence_0007 = check_presence(legato, test_name)
    if (not check_presence_0007) or (not check_presence_0004):
        test_passed = False
        swilog.error("Step 2: Kernel module have not been properly loaded")

    # Unloading required module
    swilog.step("Step 3: Unloading required module...")
    (returned_value, returned_index) = check_unloading(target,
                                                       "L_Tools_Kmod_0004",
                                                       RESULT_BUSY)
    if not returned_value:
        test_passed = False
        swilog.error("Step 3: Unloading should have been forbidden.")

    # Unloading primary module
    swilog.step("Step 5: Unloading primary module...")
    (returned_value, returned_index) = check_unloading(target, test_name,
                                                       RESULT_OK)
    if not returned_value:
        test_passed = False
        swilog.error("Step 5: Unloading should have been forbidden.")
    swilog.debug(returned_index)
    # End of script: Build the default package to reinitialise the target
    # And clean the LEGATO_ROOT directory
    assert test_passed, display_errors()
Beispiel #15
0
def L_SecureStorage_0007(target, legato):
    """Secure Storage Write API can be repeatedly called many times reliably.

    This script will
        1. Use the "Write" API to repeatedly write an item.
        2. Verify that every write is successful.

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param app_leg: fixture regarding to build, install and remove app
    """
    swilog.step("Execute L_SecureStorage_0007")
    test_title = r"Write\ Test"
    test_type = "write"
    test_cycle = "50"

    if not legato.is_app_running(APP_NAME):
        legato.start(APP_NAME)

    secure_storage_test_post(target, legato, test_title, test_type, test_cycle)

    swilog.info("[PASSED] L_SecureStorage_0007")
Beispiel #16
0
def L_SwUpdate_Flash_UbiInfo_0001(target, legato):
    """Get information from Ubi volume system/system 2.

    Check that can access ubi partitions and getting its info:
    system,rootfs...

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param app_leg: fixture to make, install and remove application
    """
    for i, value in enumerate(PARTITIONS_UBILIST):
        swilog.step("Test case %s Ubi INFO partition:" % str(i + 1))
        cmd = ("app runProc flashApp flashApp -- ubi-info " +
               PARTITIONS_UBILIST[i][0] + " " + PARTITIONS_UBILIST[i][1])
        swilog.debug(value)
        pattern = "flashApp* has exited with exit code 0"
        target.run(cmd, withexitstatus=True)
        error_msg = ("[FAILED] Getting info from" + PARTITIONS_UBILIST[i][0] +
                     ", " + PARTITIONS_UBILIST[i][1] + "failed !")
        assert legato.find_in_target_log(pattern) is False, error_msg
        legato.clear_target_log()
        time.sleep(5)
Beispiel #17
0
def L_Tools_Kmod_0008(target, legato, create_temp_workspace):
    """Verify that kmod command is not able to.

        1. Create an update package with a dependence to
        an application (load:auto)and update the target with it
        2  Verify module is loaded and application is running
        3. Unload module
        4. Load back the module
        5. Compile the default package and update the target with it

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param create_temp_workspace: fixture to create a temporary folder
    """
    # Initialisation:
    # Verify existence of environment variables and files needed.
    # Prepare compilation
    test_name = "L_Tools_Kmod_0008"
    test_passed = True
    # Compile and update target
    swilog.step("Step 1: Compiling...")
    install_system(target, legato, create_temp_workspace, test_name)

    swilog.step("Step 2: Verify mod has been loaded and app is running...")
    if not check_presence(legato, test_name):
        test_passed = False
        swilog.error("Step 2: Kernel module has not been properly loaded")
    if not legato.is_app_running("LoopingHelloWorld"):
        test_passed = False
        swilog.error("Step 2: App is not running")

    swilog.step("Step 3: Unloading...")
    (returned_value, returned_index) = check_unloading(target, test_name,
                                                       RESULT_OK)
    if not returned_value:
        test_passed = False
        swilog.error("Step 3: Kernel module has not been properly unloaded")

    swilog.step("Step 5: Loading...")
    (returned_value, returned_index) = check_loading(target, test_name,
                                                     RESULT_OK)
    if not returned_value:
        test_passed = False
        swilog.error("Step 5: Kernel module has not been properly loaded")
    swilog.debug(returned_index)
    # End of script: Build the default package to reinitialise the target
    # And clean the LEGATO_ROOT directory
    assert test_passed, display_errors()
def L_SampleApps_HelloIpc_0001(legato):
    """Script will.

        1. Make and install the test app
        2. Run the test app
        3. Check if expected messages appears in log

    :param legato: fixture to call useful functions regarding legato
    :param installapp_cleanup: fixture to make, install and remove application
    """
    swilog.step("Execute L_SampleApps_HelloIpc_0001")

    text_log1 = "Asking server to print 'Hello, world!'"
    text_log2 = "Hello, world."

    assert legato.find_in_target_log(
        text_log1), "[FAILED] Could not find out the log"
    swilog.info("[PASSED] Found client request string")

    assert legato.find_in_target_log(
        text_log2), "[FAILED] Could not find out the log"
    swilog.info("[PASSED] Found server response string")

    swilog.info("[PASSED] L_SampleApps_HelloIpc_0001")
Beispiel #19
0
def L_Tools_Kmod_0005(target, legato, create_temp_workspace):
    """Verify that kmod command able to load.

    And unload the kernel module with manual load
        1. Create an update package (load: manual)
        2. Verify loading of the module has not been performed
        3. Load the module
        4. Unload the module
        5. Compile the default package and update the target with it

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param create_temp_workspace: fixture to create a temporary folder
    """
    # Verify existence of environment variables and files needed.
    # Prepare compilation
    test_name = "L_Tools_Kmod_0005"
    test_passed = True
    # Compile and update target
    swilog.step("Step 1: Compiling...")
    install_system(target, legato, create_temp_workspace, test_name)

    swilog.step("Step 2: Verify mod has not been loaded...")
    if check_presence(legato, test_name):
        test_passed = False
        swilog.error("Step 2: Kernel module has been unexpectedly loaded")

    swilog.step("Step 3: Loading...")
    (returned_value, returned_index) = check_loading(target, test_name,
                                                     RESULT_OK)
    if not returned_value:
        test_passed = False
        swilog.error("Step 3: Kernel module has not been properly loaded")

    swilog.step("Step 5: Unloading...")
    (returned_value, returned_index) = check_unloading(target, test_name,
                                                       RESULT_OK)
    if not returned_value:
        test_passed = False
        swilog.error("Step 5: Kernel module has not been properly unloaded")
    swilog.debug(returned_index)
    # End of script: Build the default package to reinitialise the target
    # And clean the LEGATO_ROOT directory
    assert test_passed, display_errors()
Beispiel #20
0
def test_two_targets(target, target2):
    """Test sending external commands to 2 targets.

    Fill target.xml for the first target and target2.xml for the second.
    """
    swilog.step("Get legato version on first target")
    target.run("ls")
    target.run("legato version")

    swilog.step("Get legato version on second target")
    target2.run("ls")
    target2.run("legato version")

    swilog.step("Reboot the targets")
    target2.reboot()
    target.reboot()
Beispiel #21
0
def L_Tools_Kmod_0006(target, legato, create_temp_workspace):
    """Verify kmod cmd should not be able to load if it already loaded.

        1. Create an update package (Same modules as L_Tools_Kmod_0004)
        and update the target with it
        2. Verify loading of the module
        3. Try to load the module
        4. It must fail
        5. Compile the default package and update the target with it

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param create_temp_workspace: fixture to create a temporary folder
    """
    # Initialisation:
    # Verify existence of environment variables and files needed.
    # Prepare compilation
    test_name = "L_Tools_Kmod_0004"
    test_passed = True
    # Compile and update target
    swilog.step("Step 1: Compiling...")
    install_system(target, legato, create_temp_workspace, test_name)

    swilog.step("Step 2: Verify mod has been loaded...")
    if not check_presence(legato, test_name):
        test_passed = False
        swilog.error("Step 2: Kernel module has not been properly loaded")

    swilog.step("Step 5: Loading...")
    (returned_value, returned_index) = check_loading(target, test_name,
                                                     RESULT_DUPLICATE)
    if not returned_value:
        test_passed = False
        swilog.error("Step 5: Loading should have been forbidden.")
    swilog.debug(returned_index)
    # End of script: Build the default package to reinitialise the target
    # And clean the LEGATO_ROOT directory
    assert test_passed, display_errors()
Beispiel #22
0
def L_CDEF_0002(legato):
    """Verify the core functionality of the cflags.

    And cxxflags (c++) sections of cdef files.

    Args:
        legato: fixture to call useful functions regarding legato
    """
    swilog.step("Test 1: Generic cflag/cppflag test")

    # Make and install
    app_path = "%s/cdef/cflags_cxxflags/functionalityTest" % TEST_RESOURCES
    legato.make_install(APP_NAME1, app_path)

    # Cflag/cxxflag Section:
    # Search log for the strings that are printed when the Macro is found
    if not legato.find_in_target_log("cflag: CTESTFLAG response"):
        swilog.error(
            "Did not cflag response: cflag was not successfully passed to compiler"
        )

    if not legato.find_in_target_log("cppflag: CPPTESTFLAG response"):
        swilog.error(
            "Did not cppflag response: "
            "cppflag was not successfully passed to compiler"
        )

    # Remove the apps from the target
    legato.clean(APP_NAME1)

    swilog.step("Test 2: Default build flag override")
    test_path2 = "%s/cdef/cflags_cxxflags/overrideTest/c" % TEST_RESOURCES
    rsp = legato.make(os.path.join(test_path2, APP_NAME2), should_fail=True)

    # Search for the build error that arises
    # If -fvisbility=hidden was overriden by -fvisibility=default
    if re.search(
        r"libComponent_overrideCompC.so: undefined reference to \`hiddenFunction'", rsp
    ):
        # Ensure that only hiddenFunction's error is found
        # Meaning that defaultFunction's visibility was successfully overriden
        if re.search(
            "libComponent_overrideCompC.so: undefined reference "
            r"to \`defaultFunction'",
            rsp,
        ):
            swilog.error("Built-in flag was not overriden (C)")
        else:
            swilog.info("Built-in flag successfully overriden; App failed to build (C)")
    else:
        swilog.error("hiddenFunction was not hidden properly (C)")

    # Clean
    os.system(r"rm -rf _build_overrideC")
    test_path3 = "%s/cdef/cflags_cxxflags/overrideTest/cxx" % TEST_RESOURCES
    rsp = legato.make(os.path.join(test_path3, APP_NAME3), should_fail=True)

    # Search for the build error that arises
    # If -fvisbility=hidden was overriden by -fvisibility=default
    if re.search(
        r"libComponent_overrideCompCxx.so: undefined reference to \`hiddenFunction", rsp
    ):
        # Ensure that only hiddenFunction's error is found
        # Meaning that defaultFunction's visibility was successfully overriden
        if re.search(
            "libComponent_overrideCompCxx.so: undefined reference "
            r"to \`defaultFunction",
            rsp,
        ):
            swilog.error("Built-in flag was not overriden (Cxx)")
        else:
            swilog.info(
                "Built-in flag successfully overriden; App failed to build (Cxx)"
            )
    else:
        swilog.error("hiddenFunction was not hidden properly (Cxx)")

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
Beispiel #23
0
def L_UpdateCtrl_Defer_0003(target, legato):
    """Verify that le_updateCtrl_Defer() prevents all updates.

    (install a system)

    Initial Condition:
        1. Current system index is "N"

    Test Procedures:
        1. Install the app that invokes le_updateCtrl_Defer()
        onto the target device
        2. Check the current system index is "N + 1" and run the app
        3. Install Legato onto the target device
        4. Check "Updates are currently deferred" is shown from log
        5. Check the current system index is "N + 1"

    (Notes: the current system index, the current system state and
    the current system status can be verified by
    the command line "legato status")

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param install_and_clean_app: fixture to clean up environment and build app
    """
    swilog.step("Test L_UpdateCtrl_Defer_0003")

    # Set the parameter of the testUpdateCtrl app to "defer" "3"
    target.run(
        "config set apps/%s/procs/%s/args/1 defer" % (UPDATE_CTRL_APP, UPDATE_CTRL_APP)
    )
    target.run(
        "config set apps/%s/procs/%s/args/2 3" % (UPDATE_CTRL_APP, UPDATE_CTRL_APP)
    )

    # Change the probation period to 1s to
    # turn the current system into a "good" system status because
    # the current system index would be incremented after
    # A system update only if the current system
    # status is "good"
    legato.reset_probation_timer()

    # Wait for 4s allow the probation period to pass
    time.sleep(4)
    # Run the testUpdateCtrl app that will invoke le_updateCtrl_Defer()
    status, rsp = target.run("app start %s" % UPDATE_CTRL_APP, withexitstatus=True)
    swilog.debug(rsp)
    assert status == 0, "[FAILED] App could not be started."

    # Try to do an update in the target device by installing
    # a new Legato system
    # If the installation was successful then,
    # the system update attempt is proceed
    cmd = "instlegato %s/build/" % (LEGATO_ROOT)
    rsp, status = pexpect.run(cmd, withexitstatus=True)
    swilog.debug(rsp)
    assert (
        status != 0
    ), "[FAILED] Defer() allows update to \
                       happen when attempting to install a new system"
    # If the system update was successful
    # (which updates are allowed and le_updateCtrl_Defer()
    # Doesn't satisfy its functionality), mark this test case is failed
    swilog.info(
        "[PASSED] Defer() doesn't allow update to happen when"
        " attempting to install a new system"
    )

    swilog.info("[PASSED] Test L_UpdateCtrl_Defer_0003")
Beispiel #24
0
def L_UpdateCtrl_Defer_0005(target, legato, clean_test):
    """Verify that le_updateCtrl_Defer() prevents rollbacks.

    Initial Conditions:
        1. Current system index is "N"
           le_updateCtrl_FailProbation() is verified

    Test Procedures:
        1. Install the app that invokes le_updateCtrl_Defer() followed by
           le_updateCtrl_FailProbation() second
        2. Run the app
        3. Check the current system index is "N + 1"

    (Notes: the current system index, the current system state and
        the current system status can be verified by
        the command line "legato status")

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param clean_test: fixture to clean up environment
    """
    swilog.step("Test L_UpdateCtrl_Defer_0005")
    assert clean_test
    old_sys_index = 0
    new_sys_index = 0
    system_status = ""
    is_target_reboot = False

    # Get the system index from a 'good' system by setting
    # the probation period
    # to 1s to turn the system into 'good'
    legato.set_probation_timer(1)

    # Wait 3s to allow the probation period to pass
    time.sleep(3)

    # Since this test case is required to run under probation,
    # the pre-set probation
    # period has to be changed to the default, 30mins
    legato.reset_probation_timer()

    # Begin of the this TC
    legato.make_install(UPDATE_CTRL_APP, UPDATE_CTRL_PATH)
    swilog.info("[PASSED] Make and install the test app successfully.")

    # Set the parameter of the testUpdateCtrl app to
    # "defer" "5" to run this test case
    target.run(
        "config set apps/%s/procs/%s/args/1 defer" % (UPDATE_CTRL_APP, UPDATE_CTRL_APP)
    )
    target.run(
        "config set apps/%s/procs/%s/args/2 5" % (UPDATE_CTRL_APP, UPDATE_CTRL_APP)
    )

    # Store the system index before the deferral of
    # the system roll-back for verification
    old_sys_index = legato.get_current_system_index()

    target.run("app start %s" % UPDATE_CTRL_APP, withexitstatus=True)

    # ==========================================================
    # whether the reboot is necessary before the roll-back
    # if this test case is failed then, the system
    # may perform roll-back so, target device will reboot
    # ticket: LE-5080
    # ==========================================================

    # Wait 10s to check whether the system performs a roll-back
    # so that the target device will reboot.
    # If it does reboot, wait until the reboot is finished
    if target.wait_for_device_down(10) == 0:
        # Wait for the reboot is finished
        target.wait_for_reboot()
        is_target_reboot = True

    # Store the system index after the deferral of
    # the system roll-back for verification
    new_sys_index = legato.get_current_system_index()

    # Store the system status after the deferral of
    # the system roll-back for verification
    system_status = legato.get_current_system_status()

    # Since the behaviours of a system roll-back are
    #   1)Current system index rolls-back to a previous 'good' system index
    #   2)Target device reboot
    #   3)Current system status is marked as 'good' after roll-back
    #   4)Current system status is marked as 'bad' before roll-back
    #   *NOTE*: According to the implementation of FailProbation, it will mark
    #      the current system as 'bad' before checking whether there is any
    #      defer lock that the current system is holding. Therefore, it should
    #      not be part of the verification in this test case
    #   5)Previous 'good' system doesn't has the testUpdateCtrl app installed
    # If any of the previous behaviours was inspected, roll-back was not held
    # mark this test case failed
    if (
        (old_sys_index is not new_sys_index)
        or not (legato.is_app_exist(UPDATE_CTRL_APP))
        or (is_target_reboot)
        or (system_status == "good")
    ):
        swilog.error("[FAILED] defer() doesn't prevent the system roll-back")
    else:
        swilog.info("[PASSED] defer() does prevent the system roll-back")
    target.reboot()
    swilog.info("[PASSED] Test L_UpdateCtrl_Defer_0005")
Beispiel #25
0
def L_UpdateCtrl_MarkGood_0001(target, request, legato, install_and_clean_app):
    """Verify that le_updateCtrl_MarkGood(True) returns LE_OK, marks current.

    system as 'good' and terminates probation period when the system is under
    probation.

    Initial Condition:
        1. Current system is under probation
        2. Current system index is "N"

    Test Procedures:
        1. Install the app that invokes le_updateCtrl_MarkGood(True)
        onto the target device
        2. During the probation period, run the app
        3. Check the current system index is "N+ 1"
        and the current system state is marked as "good"
        4. Check "return LE_OK : The system was marked Good"
        is shown from system log

    (Notes: the current system index, the current system state
    and the current system status can be verified by
    the command line "legato status")

    :param target: fixture to communicate with the target
    :param request: object to access data
    :param legato: fixture to call useful functions regarding legato
    :param install_and_clean_app: initial and build app for testing
    """
    swilog.step("Test L_UpdateCtrl_MarkGood_0001")
    old_sys_index = 0
    new_sys_index = 0
    is_leok_return = False
    is_tc_passed = False

    old_sys_index = install_and_clean_app

    # Store the current system index which refers to the index
    # after the testUpdateCtrl app has installed onto the target
    new_sys_index = legato.get_current_system_index()

    # Set the parameter of the testUpdateCtrl app to "markGood"
    # "1" to run this test case
    target.run("config set apps/%s/procs/%s/args/1"
               " markGood" % (APP_NAME_01, APP_NAME_01))
    target.run("config set apps/%s/procs/%s/args/2 1" %
               (APP_NAME_01, APP_NAME_01))

    target.run("app start %s" % APP_NAME_01, withexitstatus=True)

    # Store the current system status after le_updateCtrl_MarkGood(True)
    # is called during the probation period for verification
    system_status = legato.get_current_system_status()

    # Capture "return LE_OK: The system was marked Good" from the system log
    # after le_updateCtrl_MarkGood(True) is called during the
    # probation period for verification
    if legato.find_in_target_log("return LE_OK:"
                                 " The system was marked Good"):
        is_leok_return = True

    # After le_updateCtrl_MarkGood(True) is called during
    # the probation period, if the current system status
    # is not marked as "good"; "return LE_OK:
    # The system was marked Good" wasn't captured in the system log;
    # The current system index is not greater than
    # the system index before running this test case by 1, mark
    # This test case failed
    if is_leok_return is False:
        swilog.error("[FAILED] MarkGood(True) doesn't return"
                     " LE_OK when system is under probation "
                     "and without any probation lock")
    elif system_status != "good":
        swilog.error("[FAILED] MarkGood(True) doesn't mark the current system"
                     " as 'good' when the system is under probation and"
                     " without any probation lock")
    elif (new_sys_index - old_sys_index) != 1:
        swilog.error("[FAILED] MarkGood(True) doesn't mark the current system"
                     " as 'good' when the system is under probation and"
                     " without any probation lock")
    else:
        swilog.info("[PASSED] MarkGood(True) marks the current system"
                    " as 'good' and returns LE_OK when the system"
                    " is under probation and without any probation lock")
        is_tc_passed = True

    end_test(is_tc_passed, request)
Beispiel #26
0
def L_UpdateCtrl_MarkGood_0006(target, request, legato, install_and_clean_app):
    """Verify that  le_updateCtrl_MarkGood(False) returns LE_DUPLICATE when.

    the system is already marked as "good".

    Initial Conditions:
        1. Current system state is marked as "good"
        2. Probation period is 10ms

    Test Procedures:
        1. Install the app that invokes le_updateCtrl_MarkGood(False)
        onto the target device
        2. After the probation period, run the app
        3. Check the current system state is marked as "good"
        4. Check "return LE_DUPLICATE : Probation has expired:
        the system has already been marked" is shown from system log

    (Notes: the current system index, the current system state and the current
    system status can be verified by the command line "legato status")

    :param target: fixture to communicate with the target
    :param request: object to access data
    :param legato: fixture to call useful functions regarding legato
    :param install_and_clean_app: initial and build app for testing
    """
    swilog.step("Test L_UpdateCtrl_MarkGood_0006")
    old_sys_index = 0
    new_sys_index = 0
    is_leduplicate_return = False
    is_tc_passed = False
    swilog.debug(install_and_clean_app)

    # Set the probation period to 1s to turn the system into "good" status
    legato.set_probation_timer(1)

    # Wait 3s to allow the probation period to pass
    time.sleep(3)

    # Set the parameter of the testUpdateCtrl app to "markGood"
    # "5" to run this test case
    target.run("config set apps/%s/procs/%s/args/1 markGood" %
               (APP_NAME_01, APP_NAME_01))
    target.run("config set apps/%s/procs/%s/args/2 6" %
               (APP_NAME_01, APP_NAME_01))

    # Store the current system index before le_updateCtrl_MarkGood(True)
    # is called for verification
    old_sys_index = legato.get_current_system_index()

    target.run("app start %s" % APP_NAME_01, withexitstatus=True)

    # Store the current system status after le_updateCtrl_MarkGood(False)
    # is called when the current status is 'good' for verification
    system_status = legato.get_current_system_status()

    # Store the current system index after le_updateCtrl_MarkGood(False)
    # is called when the current status is 'good' for verification
    new_sys_index = legato.get_current_system_index()

    # Capture "return LE_DUPLICATE: Probation has expired -
    # the system has already been marked Good"
    # from the system log after le_updateCtrl_MarkGood(False)
    # is called when the current status is 'good' for verification

    msg_log = ("return LE_DUPLICATE: Probation has expired - the system"
               " has already been marked Good")
    if legato.find_in_target_log(msg_log):
        is_leduplicate_return = True

    # After le_updateCtrl_MarkGood(False) is called
    # when the current status is 'good',
    # if the "return LE_DUPLICATE: Probation has expired -
    # the system has already been marked Good"
    # keyword is not appeared in the system log;
    # the current system status is not marked as "good";
    # the current system index is equal to the system index
    # before le_updateCtrl_MarkGood(False) is called,
    # mark this test case failed
    if is_leduplicate_return is False:
        swilog.error("[FAILED] MarkGood(False) doesn't return LE_DUPLICATE"
                     " when the current system is already marked as 'good'")
    elif old_sys_index != new_sys_index:
        swilog.error("[FAILED] MarkGood(False) modifies the system index when"
                     " the current system is already marked as 'good'")
    elif system_status != "good":
        swilog.error("[FAILED] MarkGood(False) modifies"
                     " the current system status when "
                     "the current system is already marked as 'good'")
    else:
        swilog.info("[PASSED] MarkGood(False) only returns LE_DUPLICATE when"
                    " the current system is already marked as 'good'")
        is_tc_passed = True

    end_test(is_tc_passed, request)
Beispiel #27
0
def L_UpdateCtrl_MarkGood_0004(target, request, legato, install_and_clean_app):
    """Verify that le_updateCtrl_MarkGood(False) returns LE_BUSY if someone.

    holds a probation lock.

    Initial Condition:
        1. le_updateCtrl_LockProbation() is verified
        current system is under probation

    Test Procedures:
        1. Install the app that invokes le_updateCtrl_LockProbation()
        first and  le_updateCtrl_MarkGood(False)
        second onto the target device.
        2. During the probation period, run the app
        3. Check "return LE_BUSY: Someone holds
        a probation lock" is shown from system log
        4. Check the system is under probation

    (Notes: the current system index, the current system state
    and the current system status can be verified by
    the command line "legato status")

    :param target: fixture to communicate with the target
    :param request: object to access data
    :param legato: fixture to call useful functions regarding legato
    :param install_and_clean_app: initial and build app for testing
    """
    swilog.step("Test L_UpdateCtrl_MarkGood_0004")
    old_sys_index = 0
    new_sys_index = 0
    is_lebusy_return = False
    is_tc_passed = False

    old_sys_index = install_and_clean_app

    # Set the parameter of the testUpdateCtrl app
    # to "markGood" "4" to run this testcase
    target.run("config set apps/%s/procs/%s/args/1 markGood" %
               (APP_NAME_01, APP_NAME_01))
    target.run("config set apps/%s/procs/%s/args/2 4" %
               (APP_NAME_01, APP_NAME_01))

    rsp = target.run("app start %s" % APP_NAME_01, withexitstatus=True)
    swilog.info(rsp)

    # Now, the current system has a probation lock
    # store the current system index after after le_updateCtrl_MarkGood(False)
    # is called when there is a probation lock for verification
    new_sys_index = legato.get_current_system_index()

    # Store the current system status after le_updateCtrl_MarkGood(False)
    # is called when there is a probation lock for verification
    system_status = legato.get_current_system_status()

    # Capture "return LE_BUSY: Someone holds a probation lock"
    # from the system log after le_updateCtrl_MarkGood(False) is called when
    # there is a probation lock for verification
    if legato.find_in_target_log("return LE_BUSY:"
                                 " Someone holds a probation lock"):
        is_lebusy_return = True

    # After le_updateCtrl_MarkGood(False) is called when there is a probation
    # lock, if the current system status is not under probation;
    # "return LE_BUSY: Someone holds a probation lock" is not appeared
    # in the system log; the current system
    # index is not greater than the system index before running
    # this test case by 1,
    # Mark this test case "failed"
    if is_lebusy_return is False:
        swilog.error("[FAILED] MarkGood(False) doesn't return LE_BUSY when"
                     " the system is under probation "
                     "and there is a probation lock")
    elif system_status[0:5] != "tried":
        swilog.error("[FAILED] MarkGood(False) ends the probation period when"
                     " the system is under probation and"
                     " there is a probation lock")
    elif (new_sys_index - old_sys_index) != 1:
        swilog.error("[FAILED] MarkGood(False) modifies the system"
                     " index when the system is under probation and"
                     " there is a probation lock")
    else:
        swilog.info("[PASSED] MarkGood(False) only returns LE_BUSY when the "
                    "system is under probation and there is a probation lock")
        is_tc_passed = True

    # After StartTC, the current system is marked as "good' and
    # the current system holds a probation lock reboot the system to clear
    # the probation lock before performing the clean up on the target
    target.reboot()
    end_test(is_tc_passed, request)
Beispiel #28
0
def L_UpdateCtrl_Defer_0001(target):
    """Verify that le_updateCtrl_Defer() prevents all updates.

    (remove an app)

    Initial Condition:
        1. Current system index is "N"

    Test Procedures:
        1. Install the app that invokes le_updateCtrl_Defer()
        onto the target device
        2. Check the current system index is "N + 1" and run the app
        3. Remove the same app
        4. Check "Updates are currently deferred" is shown from log
        5. Check the app is still existed in the target device
        (verified by the command line "app list")
        6. Check the current system index is "N + 1"

    (Notes: the current system index, the current system state and
    the current system status can be verified by
    the command line "legato status")

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param install_and_clean_app: fixture to clean up environment and build app
    """
    swilog.step("Test L_UpdateCtrl_Defer_0001")

    # Set the parameters of the testUpdateCtrl app to
    # "defer" "1" to run this test case
    target.run(
        "config set apps/%s/procs/%s/args/1 defer" % (UPDATE_CTRL_APP, UPDATE_CTRL_APP)
    )
    target.run(
        "config set apps/%s/procs/%s/args/2 1" % (UPDATE_CTRL_APP, UPDATE_CTRL_APP)
    )

    # Run the testUpdateCtrl app that will invoke le_updateCtrl_Defer()
    status, rsp = target.run("app start %s" % UPDATE_CTRL_APP, withexitstatus=True)
    swilog.debug(rsp)
    assert status == 0, "[FAILED] App could not be started."

    # Try to do a update in the target device by removing
    # the testUpdateCtrl app while the
    # Current system should hold a defer lock
    # If the removal was successful then, the system update is proceed
    status, rsp = target.run("app remove %s" % UPDATE_CTRL_APP, withexitstatus=True)
    swilog.debug(rsp)
    assert (
        status == 1
    ), "[FAILED] Defer() allows update to happen when \
attempting to remove an app."

    # If the system update was successful,
    # the update was allowed and mark this TC failed
    swilog.info(
        "[PASSED] Defer() doesn't allow update to"
        " happen when attempting to remove an app"
    )

    swilog.info("[PASSED] Test L_UpdateCtrl_Defer_0001")
Beispiel #29
0
def L_UpdateCtrl_MarkGood_0003(target, request, legato, install_and_clean_app):
    """Verify that le_updateCtrl_MarkGood(True) returns LE_OK to set current.

    system 'good' even if someone holds a probation lock.

    Initial Condition:
        1. le_updateCtrl_LockProbation() is verified
        2. Current system index is "N"

    Test Procedures:
        1. Install the app that invokes le_updateCtrl_LockProbation() first
        and  le_updateCtrl_MarkGood(True)  second onto the target device
        2. During the probation period, run the app
        3. Check the current index is "N + 1" and
        the current system state is marked as "good"
        4. Check "return LE_OK : The system was marked Good" is shown
        from system log

    (Notes: the current system index, the current system state
    and the current system status can be verified by
    the command line "legato status")

    :param target: fixture to communicate with the target
    :param request: object to access data
    :param legato: fixture to call useful functions regarding legato
    :param install_and_clean_app: initial and build app for testing
    """
    swilog.step("Test L_UpdateCtrl_MarkGood_0003")
    old_sys_index = 0
    new_sys_index = 0
    is_leok_return = False
    is_tc_passed = False

    old_sys_index = install_and_clean_app

    # Set the parameter of the testUpdateCtrl app to "markGood"
    # "3" to run this test case
    target.run("config set apps/%s/procs/%s/args/1"
               " markGood" % (APP_NAME_01, APP_NAME_01))
    target.run("config set apps/%s/procs/%s/args/2 3" %
               (APP_NAME_01, APP_NAME_01))

    target.run("app start %s" % APP_NAME_01, withexitstatus=True)

    # Now, the current system has a probation lock
    # store the current system index after le_updateCtrl_MarkGood(True)
    # is called when there is a probation lock for verification
    new_sys_index = legato.get_current_system_index()

    # Store the current system status after le_updateCtrl_MarkGood(True)
    # is called when there is a probation lock for verification
    system_status = legato.get_current_system_status()

    # Capture "return LE_OK: The system was marked Good" from
    # the system log after le_updateCtrl_MarkGood(True) is called
    # when there is a probation lock for verification
    if legato.find_in_target_log("return LE_OK:"
                                 " The system was marked Good"):
        is_leok_return = True

    # After le_updateCtrl_MarkGood(True) is
    # called when there is a probation lock,
    # if the current system status is not marked as "good";
    # "return LE_OK: The system was marked Good"
    # is not appeared in the system log; the current system index
    # is not greater than the system index
    # before running this test case by 1, mark this test case failed
    if is_leok_return is False:
        swilog.error("[FAILED] MarkGood(True) doesn't return LE_OK"
                     " when system is under probation"
                     " and there is a probation lock")
    elif system_status != "good":
        swilog.error("[FAILED] MarkGood(True) doesn't mark the current system"
                     " as 'good' when the system is under probation and"
                     " there is a probation lock")
    elif (new_sys_index - old_sys_index) != 1:
        swilog.error("[FAILED] MarkGood(True) doesn't mark the current system"
                     " as 'good' when the system is under probation and"
                     " there is a probation lock")
    else:
        swilog.info("[PASSED] MarkGood(True) marks the current system"
                    " as 'good' when the system is under probation"
                    " and there is a probation lock")
        is_tc_passed = True

    # After StartTC, the current system is marked as
    # "good' and the current system holds a probation lock
    # reboot the system to clear the probation lock
    # before performing the clean up on the target
    target.reboot()
    end_test(is_tc_passed, request)
def L_UpdateCtrl_UnlockProbation_0001(target, legato):
    """Verify that le_updateCtrl_UnLockProbation().

    is ignored if the probation.
    period has already ended and the process who called
    le_updateCtrl_UnLockProbation() is terminated.

    Initial Condition:
        1. Probation period is 10ms
        2. Current system index is "N"

    Test Procedures:
    1. Install the app that invokes le_updateCtrl_UnLockProbation()
    onto the target device
    2. After the probation period, check the current system index is
    "N + 1" and run the app
    3. Check the current system state is marked as "good" and
    the current system index is "N + 1"
    4. Check the app doesn't crash and doesn't exit wilth
    a non-zero value (LE-6183)

    (Notes: the current system index, the current system state and the current
    system status can be verified by the command line "legato status")

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    :param install_and_clean_app: initial environment and build app
    """
    swilog.step("Test L_UpdateCtrl_UnlockProbation_0001")
    is_tc_passed = False

    # Set the probation period to 1s so that
    # the system status can turn into 'good'
    legato.set_probation_timer(1)

    # Wait 2s to allow the probation period to pass
    time.sleep(2)

    # Set the parameter of the testUpdateCtrl app to "unLockProbation"
    # "1" to run this test case
    target.run("config set apps/%s/procs"
               "/%s/args/1 unLockProbation" % (APP_NAME_01, APP_NAME_01))
    target.run("config set apps/%s/procs"
               "/%s/args/2 1" % (APP_NAME_01, APP_NAME_01))

    # Store the system index before le_updateCtrl_UnlockProbation()
    # is called when the system is already 'good' for verification
    old_sys_index = legato.get_current_system_index()

    target.run("app start %s" % APP_NAME_01)

    # Store the system index after le_updateCtrl_UnlockProbation()
    # is called when the system is already 'good' for verification
    new_sys_index = legato.get_current_system_index()

    # Store the system status after le_updateCtrl_UnlockProbation()
    # is called when the system is already 'good' for verification
    system_status = legato.get_current_system_status()

    # After le_updateCtrl_UnlockProbation() is called when
    # the system is already 'good', if the current system status is not "good"
    # or the system indexes are different before and after
    # le_updateCtrl_UnlockProbation() is called, mark this test case failed
    if system_status != "good":
        swilog.error("[FAILED] UnlockProbation() modifies the current system"
                     " status when the probation period has already ended")
    elif old_sys_index != new_sys_index:
        swilog.error("[FAILED] UnlockProbation() modifies the system index"
                     " when the probation period has already ended")
    else:
        swilog.info("[PASSED] UnlockProbation() is ignored when"
                    " the probation period has already ended")
        is_tc_passed = True

    assert is_tc_passed, "[FAILED] L_UpdateCtrl_UnlockProbation_0001"
    swilog.info("[PASSED] L_UpdateCtrl_UnlockProbation_0001")