Exemple #1
0
def L_CDEF_0001(target, legato, tmpdir):
    """Verify the functionality of the "bundles" section in cdef files.

    Args:
        target: fixture to communicate with the target
        legato: fixture to call useful functions regarding legato
        tmpdir: fixture to provide a temporary directory
             unique to the test invocation
        test_init: fixture to init and clean up the test
    """
    # Go to temp directory
    os.chdir(str(tmpdir))
    legato.make_install(APP_NAME, "%s/cdef/bundles" % TEST_RESOURCES)

    # Check that bundled file was included
    path = "/legato/systems/current/appsWriteable/%s/bin" % APP_NAME
    is_file_on_target(target, path, TEST_FILE)

    # Check that bundled directory and its contents were included
    is_directory_on_target(target, path, TEST_FOLDER)
    is_file_on_target(target, path, "%s/file1.txt" % TEST_FOLDER)
    is_directory_on_target(target, path, "%s/folder1" % TEST_FOLDER)
    is_file_on_target(target, path, "%s/folder1/file2.txt" % TEST_FOLDER)

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
Exemple #2
0
def display_errors():
    """Display errors.

    :param output: errors
    """
    output = "\n"
    for err in swilog.get_error_list():
        output += err + "\n"
    return output
Exemple #3
0
def L_ADEF_0006(legato):
    """Check link (Validate defect #2472).

    Args:
        legato: fixture to call useful functions regarding legato
        app_leg: fixture to make install application
                 and cleanup it after the test
    """
    verify_run_correctly(legato)

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
def L_CDEF_0016(legato):
    """Verify that "mksys" will be successful if optional client-side IPC API.

    is bound with customized server-side interfaces.

    Args:
        legato: fixture to call useful functions regarding legato
    """
    build_sys(legato, "customizedAPI", "clientIPC", "mksys", "optional",
              "withBindings")

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
def L_CDEF_0014(legato):
    """Verify "mksys" will not complain if there's no optional client-side.

    IPC API to be bound with customized server-side interfaces.

    Args:
        legato: fixture to call useful functions regarding legato
    """
    build_sys(legato, "customizedAPI", "clientIPC", "mksys", "optional",
              "withoutBindings")

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
Exemple #6
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_CDEF_0004(legato):
    """Verify the provides and requires sections of cdef files.

    Args:
        legato: fixture to call useful functions regarding legato
    """
    # Provide/Require Section:
    # Look for string to ensure apps are communicating using API
    rsp = legato.find_in_target_log("Client says 'Hello, world!'")
    if rsp:
        swilog.info("Found Server response string")
    else:
        swilog.error("Did not find Server response string")

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
def L_CDEF_0028(target, legato):
    """Verify the binding is not existed after app's deployment.

    when its client-side IPC API is not bounded to any server-side API
    with the interface option: [optional]
    Verification:
    This test case will mark as "failed" when

        1. Arbitrary binding is existed in the output of the command line \
        "sdir list"

    This script will

         1. Build and install the test app, optional_withoutBindings
         2. Run the command line in the target, "sdir list"
         3. Check the existence of the binding

    :param target: fixture to communicate with the target
    :param legato: fixture to call useful functions regarding legato
    """
    cmd = "/legato/systems/current/bin/sdir list"

    # LogClient is the default hardcoded binding which created
    # When any user app has been deployed onto the target
    log_client_binding_name = "LogClient"

    # Make and install
    legato.make_install(APP_NAME, APP_PATH)

    rsp = target.run(cmd)
    if re.search(APP_NAME, rsp):
        if re.search(log_client_binding_name, rsp):
            swilog.info("Arbitrary binding does not exist after app's "
                        "deployment when its client-side IPC API is not "
                        "bounded to any server-side API with the interface "
                        "option: [optional]")
    else:
        swilog.error("Arbitrary binding does not exist after app's deployment "
                     "when its client-side IPC API is not bounded to any "
                     "server-side API with the interface option: [optional]")

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
def L_CDEF_0024(legato):
    """Verify that "mksys" will be successful if client-side IPC API options.

    are optional and manual start and to require customized API.

    Args:
        legato: fixture to call useful functions regarding legato
    """
    build_sys(
        legato,
        "customizedAPI",
        "clientIPC",
        "mksys",
        "optional_manualStart",
        "withoutBindings",
    )

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
def L_CDEF_0027(legato):
    """Verify that "mksys" will complain "[optional]" is only for client-side.

    IPC option when the server app provides customized API.

    Args:
        legato: fixture to call useful functions regarding legato
    """
    build_sys(
        legato,
        "customizedAPI",
        "serverIPC",
        "mksys",
        "optional",
        "withoutBindings",
        build_status=True,
    )

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
def L_CDEF_0023(legato):
    """Verify that "mkapp" will be unsuccessful if client-side IPC API options.

    are types-only and optional and to require customized API.

    Args:
        legato: fixture to call useful functions regarding legato
    """
    build_app(
        legato,
        "customizedAPI",
        "clientIPC",
        "mkapp",
        "optional_typesOnly",
        "withoutBindings",
        build_status=True,
    )

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
def L_CDEF_0021(legato):
    """Verify that requires section can't have duplicated API.

    (with interface option)

    Args:
        legato: fixture to call useful functions regarding legato
    """
    build_app(
        legato,
        "customizedAPI",
        "clientIPC",
        "mkapp",
        "optional_typesOnly",
        "withBindings",
        build_status=True,
    )

    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
Exemple #13
0
def test_swilog_error_memorization(target):
    """Execute several tests and capture swilog errors.

    Use swilog.error to log all the encountered errors.
    The final verdict will be passed if there is no stored errors.

    Args:
        target: fixture to communicate with the target
    """
    if " legato " not in target.run("ls /"):
        swilog.error("/legato is not present")

    if " tmp " not in target.run("ls /"):
        swilog.error("/tmp is not present")

    if " my_test_folder " not in target.run("ls /tmp"):
        swilog.error("/tmp/my_test_folder is not present")

    # Test is PASS if only /legato, /tmp and /tmp/my_test_folder are present
    failed_testcases_list = swilog.get_error_list()
    if failed_testcases_list != []:
        assert 0, "Some tests failed:\n%s" % "\n".join(failed_testcases_list)
Exemple #14
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)