diff options
3 files changed, 127 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/memtool/memtool/run-ptest b/meta-oe/recipes-devtools/memtool/memtool/run-ptest new file mode 100644 index 0000000000..865da9f69e --- /dev/null +++ b/meta-oe/recipes-devtools/memtool/memtool/run-ptest | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # SPDX-FileCopyrightText: 2024 Bosch Sicherheitssysteme GmbH | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: MIT | ||
| 6 | |||
| 7 | fail_count=0 | ||
| 8 | all_count=0 | ||
| 9 | |||
| 10 | for test_suite in tests/test_* | ||
| 11 | do | ||
| 12 | if "./$test_suite" | ||
| 13 | then | ||
| 14 | echo "PASS: $test_suite" | ||
| 15 | else | ||
| 16 | echo "FAIL: $test_suite" | ||
| 17 | fail_count=$((fail_count + 1)) | ||
| 18 | fi | ||
| 19 | all_count=$((all_count + 1)) | ||
| 20 | done | ||
| 21 | |||
| 22 | if [ $fail_count -eq 0 ] | ||
| 23 | then | ||
| 24 | echo "PASS: All $all_count tests passed" | ||
| 25 | else | ||
| 26 | echo "FAIL: $fail_count of $all_count tests failed" | ||
| 27 | fi | ||
diff --git a/meta-oe/recipes-devtools/memtool/memtool/test_read_write_plainfiles.sh b/meta-oe/recipes-devtools/memtool/memtool/test_read_write_plainfiles.sh new file mode 100644 index 0000000000..a74975d392 --- /dev/null +++ b/meta-oe/recipes-devtools/memtool/memtool/test_read_write_plainfiles.sh | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # SPDX-FileCopyrightText: 2024 Bosch Sicherheitssysteme GmbH | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: MIT | ||
| 6 | |||
| 7 | # This script verifies the behavior of memtool against plain files. | ||
| 8 | |||
| 9 | readonly PLAIN_FILE=$(mktemp) | ||
| 10 | FAIL_COUNT=0 | ||
| 11 | |||
| 12 | setup() { | ||
| 13 | echo "Hello World!" >"$PLAIN_FILE" | ||
| 14 | } | ||
| 15 | |||
| 16 | teardown() { | ||
| 17 | rm "$PLAIN_FILE" | ||
| 18 | } | ||
| 19 | |||
| 20 | verify() { | ||
| 21 | ACTUAL=$1 | ||
| 22 | EXPECTED=$2 | ||
| 23 | TEST_NAME=$3 | ||
| 24 | |||
| 25 | if [ "$ACTUAL" = "$EXPECTED" ]; then | ||
| 26 | echo "pass: $TEST_NAME" | ||
| 27 | else | ||
| 28 | echo "FAIL: $TEST_NAME" | ||
| 29 | echo " Expected: $EXPECTED" | ||
| 30 | echo " Actual: $ACTUAL" | ||
| 31 | FAIL_COUNT=$((FAIL_COUNT + 1)) | ||
| 32 | fi | ||
| 33 | } | ||
| 34 | |||
| 35 | # Test Case: Verifies that the expected string of bytes is read from a plain file starting from | ||
| 36 | # the offset 6 and reading 6 bytes. | ||
| 37 | test_memtool_read() { | ||
| 38 | EXPECTED="00000006: 57 6f 72 6c 64 21 World!" | ||
| 39 | ACTUAL=$(memtool md -s "$PLAIN_FILE" -b 0x6+6) | ||
| 40 | verify "$ACTUAL" "$EXPECTED" "memtool read from plain file" | ||
| 41 | } | ||
| 42 | |||
| 43 | # Test Case 2: Verifies that the expected string of bytes is written to a plain file starting from | ||
| 44 | # and then read the result. | ||
| 45 | test_memtool_write() { | ||
| 46 | # Usage of 'od' ensures correct endianess. | ||
| 47 | readonly replace_str_bytes=$(echo "Yocto!" | od -t d4 -A n) | ||
| 48 | |||
| 49 | # shellcheck disable=SC2086 # We want to pass the bytes as separate arguments. | ||
| 50 | memtool mw -d "$PLAIN_FILE" 0x6+6 $replace_str_bytes | ||
| 51 | |||
| 52 | EXPECTED="00000006: 59 6f 63 74 6f 21 Yocto!" | ||
| 53 | ACTUAL=$(memtool md -s "$PLAIN_FILE" -b 0x6+6) | ||
| 54 | verify "$ACTUAL" "$EXPECTED" "memtool write to plain file" | ||
| 55 | } | ||
| 56 | |||
| 57 | for test_case in $(declare -F | grep test_memtool_ | cut -f 3 -d ' '); do | ||
| 58 | setup | ||
| 59 | $test_case | ||
| 60 | teardown | ||
| 61 | done | ||
| 62 | |||
| 63 | if [ $FAIL_COUNT -eq 0 ]; then | ||
| 64 | echo "Test Passed: memtool plain file read/write functionality is correct." | ||
| 65 | exit 0 | ||
| 66 | else | ||
| 67 | echo "Test FAILED: memtool plain file read/write functionality is incorrect. Check the logs." | ||
| 68 | exit 1 | ||
| 69 | fi | ||
diff --git a/meta-oe/recipes-devtools/memtool/memtool_2018.03.0.bb b/meta-oe/recipes-devtools/memtool/memtool_2018.03.0.bb new file mode 100644 index 0000000000..1e2e93bcd5 --- /dev/null +++ b/meta-oe/recipes-devtools/memtool/memtool_2018.03.0.bb | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | # SPDX-FileCopyrightText: 2024 Bosch Sicherheitssysteme GmbH | ||
| 2 | # | ||
| 3 | # SPDX-License-Identifier: MIT | ||
| 4 | |||
| 5 | SUMMARY = "A tool to manipulate and read memory mapped registers" | ||
| 6 | DESCRIPTION = "memtool is a program that allows to access memory mapped registers. This is useful \ | ||
| 7 | to inspect and modify registers from the command line. memtool can also operate on plain files, \ | ||
| 8 | and access PHY registers." | ||
| 9 | HOMEPAGE = "https://github.com/pengutronix/memtool" | ||
| 10 | BUGTRACKER = "https://github.com/pengutronix/memtool/issues" | ||
| 11 | SECTION = "devtool" | ||
| 12 | |||
| 13 | LICENSE = "GPL-2.0-only" | ||
| 14 | LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" | ||
| 15 | |||
| 16 | SRC_URI = " \ | ||
| 17 | http://www.pengutronix.de/software/memtool/downloads/memtool-${PV}.tar.xz \ | ||
| 18 | file://run-ptest \ | ||
| 19 | file://test_read_write_plainfiles.sh \ | ||
| 20 | " | ||
| 21 | |||
| 22 | SRC_URI[sha256sum] = "87cb7175266ff3a00a9c1f541c4c6c93693ffbe8dcc0d97a60d13c45ff860900" | ||
| 23 | |||
| 24 | inherit autotools ptest | ||
| 25 | |||
| 26 | do_install_ptest () { | ||
| 27 | install -d ${D}${PTEST_PATH}/tests | ||
| 28 | install -m 0755 ${UNPACKDIR}/test_* ${D}${PTEST_PATH}/tests | ||
| 29 | } | ||
| 30 | |||
| 31 | RDEPENDS:${PN}-ptest += "bash coreutils" | ||
