Tests: implement REUSE with SPDX identifiers
[lttng-ust.git] / tests / unit / libcommon / test_get_cpu_mask_from_sysfs
CommitLineData
fb0f6ca9 1#!/bin/bash
89a8858d
MJ
2
3# SPDX-FileCopyrightText: 2023 EfficiOS, Inc
4#
fb0f6ca9
MJ
5# SPDX-License-Identifier: LGPL-2.1-only
6
7if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then
8 UTILSSH="$UST_TESTS_SRCDIR/utils/utils.sh"
9else
10 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
11fi
12
13# shellcheck source=../../utils/utils.sh
14source "$UTILSSH"
15
16# shellcheck source=../../utils/tap.sh
17source "$UST_TESTS_SRCDIR/utils/tap.sh"
18
19CURDIR="${UST_TESTS_BUILDDIR}/unit/libcommon"
20
21NUM_TESTS=8
22
23TESTFILE=$(mktemp)
24
25populate_testfile() {
26 local cpumask="$1"
27
28 # shellcheck disable=SC2059
29 printf "$cpumask" > "$TESTFILE"
30}
31
32test_test_get_cpu_mask_from_sysfs() {
33 local cpumask="$1"
34 local result
35
36 # Without '\n'
37 populate_testfile "$cpumask"
38 result=$("${CURDIR}/get_cpu_mask_from_sysfs" "$TESTFILE")
39 test "$cpumask" == "$result"
40 ok $? "test_get_cpu_mask_from_sysfs - without '\n' expected: '$cpumask', result: '$result'"
41
42 # With '\n'
43 populate_testfile "$cpumask\n"
44 result=$("${CURDIR}/get_cpu_mask_from_sysfs" "$TESTFILE")
45 test "$cpumask" == "$result"
46 ok $? "test_get_cpu_mask_from_sysfs - with '\n' expected: '$cpumask', result: '$result'"
47}
48
49plan_tests $NUM_TESTS
50
51test_test_get_cpu_mask_from_sysfs ""
52test_test_get_cpu_mask_from_sysfs "0"
53test_test_get_cpu_mask_from_sysfs "0-3"
54test_test_get_cpu_mask_from_sysfs "0,3-7,9"
This page took 0.024581 seconds and 4 git commands to generate.