Commit 607363f6 authored by Robert Drab's avatar Robert Drab
Browse files

Run ACTS ltp open_posix_testsuite subset

ACTS contains only open_posix_testsuite ltp subset. Explicit list
of test cases is hardcoded in respective ACTS BUILD.gn file.

Only tests from the list are being executed. Output is formatted
into junit xml report.

Closes: #15

Signed-off-by: Robert Drab's avatarRobert Drab <robert.drab@huawei.com>
parent e7533056
Pipeline #1858 passed with stages
in 43 minutes and 24 seconds
# SPDX-License-Identifier: Apache-2.0
#
# Copyright 2021 Huawei Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
summary: ltp open_posix_testsuite interfaces tests
environment:
LTP_ROOT_PATH: /opt/ltp
OPEN_POSIX_TESTSUITE_REL_PATH: open_posix_testsuite/conformance/interfaces
TESTS_PATH: $LTP_ROOT_PATH/testcases/$OPEN_POSIX_TESTSUITE_REL_PATH
TESTS_LIST_FILE: .acts-ltp-tests-list
TEST_CLASS_NAME: open_posix_testsuite
TEST_RESULTS_FILE: ActsOpenPosixTestsuite.xml
TEST_CASES_DIR: .test-cases
TEST_SUITES_LIST_FILE: $TEST_CASES_DIR/.test-suite-list
prepare: |
# ACTS open_posix_testsuite subset is defined as build_args variable
# in the respective BUILD.gn file. Below loop reads the file line by line
# and executes all found tests. Searching is regex based, test cases list
# is identified as a list of comma-separated quoted strings, one in each
# line, e.g.:
# ` "sched_getparam/sched_getparam_1-1.run-test",`
# starting after line containing:
# ` build_args = [`
# and ending with:
# ` ]`
# with no empty lines allowed in between.
# List of tests to be executed is stored in the .acts-ltp-tests-list file
touch "$TESTS_LIST_FILE"
INSIDE_TEST_CASES=false
line=
while IFS= read -r line; do
if $INSIDE_TEST_CASES
then
echo "$line" | grep -q "^\s*\]\s*$" && break
TEST_BIN=$(echo "$line" | sed 's|^\s*\"\(.*\)\",\s*$|\1|')
echo "$TEST_BIN" >> "$TESTS_LIST_FILE"
else
echo "$line" | grep -q "^\s*build_args = \[\s*$" && INSIDE_TEST_CASES=true
fi
done < "$SPREAD_PATH/$OPEN_POSIX_TESTSUITE_REL_PATH/BUILD.gn"
mkdir -p "$TEST_CASES_DIR"
while IFS="/" read -r TEST_SUITE TEST_CASE; do
echo "$TEST_SUITE"
echo "$TEST_CASE" >> "$TEST_CASES_DIR/$TEST_SUITE-test-cases"
done < "$TESTS_LIST_FILE" | sort | uniq > "$TEST_SUITES_LIST_FILE"
restore: |
rm "$TESTS_LIST_FILE"
rm "$TEST_SUITES_LIST_FILE"
rm -rf "$TEST_CASES_DIR"
execute: |
# ACTS LTP open_posix_testsuite subset output wrapped into junit xml
# with identified test suite in it's own section.
TESTS_TIMESTAMP=$(date --utc +"%FT%T")
TOTAL_NUMBER_OF_FAILURES=0
TOTAL_NUMBER_OF_TESTS=0
while IFS= read -r TEST_SUITE; do
while IFS= read -r TEST_CASE; do
TOTAL_NUMBER_OF_TESTS=$((TOTAL_NUMBER_OF_TESTS + 1))
TEST_RESULT=0
TEST_OUTPUT=$("$TESTS_PATH/$TEST_SUITE/$TEST_CASE") || TEST_RESULT=$?
# Escaping double quotes in the test output not to break xml
TEST_OUTPUT_ESCAPED=$(echo "$TEST_OUTPUT" | sed 's|"|\\"|g')
TEST_CASE_NAME=$(echo "$TEST_CASE" | sed 's|\(.*\)\.run-test|\1|')
echo "<testcase name=\"$TEST_CASE_NAME\" status=\"run\" classname=\"$TEST_CLASS_NAME\" >"
if test "$TEST_RESULT" -ne 0
then
echo "<failure message=\"$TEST_OUTPUT_ESCAPED\" />"
TOTAL_NUMBER_OF_FAILURES=$((TOTAL_NUMBER_OF_FAILURES + 1))
fi
echo "</testcase>"
done < "$TEST_CASES_DIR/$TEST_SUITE-test-cases" >> "$TEST_CASES_DIR/$TEST_SUITE.results"
done < "$TEST_SUITES_LIST_FILE"
# Below final junit xml is assembled
{
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
echo "<testsuites tests=\"$TOTAL_NUMBER_OF_TESTS\" failures=\"$TOTAL_NUMBER_OF_FAILURES\""
echo " timestamp=\"$TESTS_TIMESTAMP\" name=\"AllTests\">"
while IFS= read -r TEST_SUITE; do
NUMBER_OF_TESTS=$(wc -l < "$TEST_CASES_DIR/$TEST_SUITE-test-cases")
NUMBER_OF_FAILURES=$(grep -c "<failure " "$TEST_CASES_DIR/$TEST_SUITE.results") || true
echo "<testsuite name=\"$TEST_SUITE\" tests=\"$NUMBER_OF_TESTS\""
echo " failures=\"$NUMBER_OF_FAILURES\">"
cat "$TEST_CASES_DIR/$TEST_SUITE.results"
echo "</testsuite>"
done < "$TEST_SUITES_LIST_FILE"
echo "</testsuites>"
} >> "$TEST_RESULTS_FILE"
artifacts: [ActsOpenPosixTestsuite.xml]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment