summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-devtools/memtool/memtool/run-ptest27
-rw-r--r--meta-oe/recipes-devtools/memtool/memtool/test_read_write_plainfiles.sh69
-rw-r--r--meta-oe/recipes-devtools/memtool/memtool_2018.03.0.bb31
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
7fail_count=0
8all_count=0
9
10for test_suite in tests/test_*
11do
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))
20done
21
22if [ $fail_count -eq 0 ]
23then
24 echo "PASS: All $all_count tests passed"
25else
26 echo "FAIL: $fail_count of $all_count tests failed"
27fi
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
9readonly PLAIN_FILE=$(mktemp)
10FAIL_COUNT=0
11
12setup() {
13 echo "Hello World!" >"$PLAIN_FILE"
14}
15
16teardown() {
17 rm "$PLAIN_FILE"
18}
19
20verify() {
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.
37test_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.
45test_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
57for test_case in $(declare -F | grep test_memtool_ | cut -f 3 -d ' '); do
58 setup
59 $test_case
60 teardown
61done
62
63if [ $FAIL_COUNT -eq 0 ]; then
64 echo "Test Passed: memtool plain file read/write functionality is correct."
65 exit 0
66else
67 echo "Test FAILED: memtool plain file read/write functionality is incorrect. Check the logs."
68 exit 1
69fi
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
5SUMMARY = "A tool to manipulate and read memory mapped registers"
6DESCRIPTION = "memtool is a program that allows to access memory mapped registers. This is useful \
7to inspect and modify registers from the command line. memtool can also operate on plain files, \
8and access PHY registers."
9HOMEPAGE = "https://github.com/pengutronix/memtool"
10BUGTRACKER = "https://github.com/pengutronix/memtool/issues"
11SECTION = "devtool"
12
13LICENSE = "GPL-2.0-only"
14LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
15
16SRC_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
22SRC_URI[sha256sum] = "87cb7175266ff3a00a9c1f541c4c6c93693ffbe8dcc0d97a60d13c45ff860900"
23
24inherit autotools ptest
25
26do_install_ptest () {
27 install -d ${D}${PTEST_PATH}/tests
28 install -m 0755 ${UNPACKDIR}/test_* ${D}${PTEST_PATH}/tests
29}
30
31RDEPENDS:${PN}-ptest += "bash coreutils"