xref: /illumos-gate/usr/src/test/util-tests/tests/mdb/numbers/tst.prefsym.ksh (revision dd72704bd9e794056c558153663c739e2012d721)
1#!/usr/bin/ksh
2#
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright 2021 Oxide Computer Company
16#
17
18#
19# This test is trying to ensure that mdb still respects symbols over
20# numbers that look similar.
21#
22
23set -o pipefail
24
25tst_root="$(dirname $0)/.."
26tst_prog="$tst_root/progs/number_symbol"
27tst_sym0="ffffabcde00"
28tst_sym1="ffffab_cde00"
29tst_sym2="_007"
30tst_out=
31tst_err=0
32
33$MDB -e "$tst_sym0=K" $tst_prog | grep -q "$tst_sym0"
34if (( $? == 0 )); then
35	printf >&2 "%s=K somehow returned itself, did it become a number?\n" \
36	    "$tst_sym0"
37fi
38
39$MDB -e "$tst_sym0/K | ::eval ./s" $tst_prog | grep -q 'Am I a string?'
40if (( $? != 0 )); then
41	printf >&2 "Failed to find expected output for %s\n" "$tst_sym0"
42	tst_err=1
43fi
44
45#
46# We grep against tst_sym0 as if mdb does interpret this as a number,
47# then it'll show it without the '_' characters.
48#
49$MDB -e "$tst_sym1=K" $tst_prog | grep -q "$tst_sym0"
50if (( $? == 0 )); then
51	printf >&2 "%s=K somehow returned itself, did it become a number?\n" \
52	    "$tst_sym0"
53	tst_err=1
54fi
55
56$MDB -e "$tst_sym1/K | ::eval ./s" $tst_prog | grep -q 'I am not a string'
57if (( $? != 0 )); then
58	printf >&2 "Failed to find expected output for %s\n" "$tst_sym1"
59	tst_err=1
60fi
61
62$MDB -e "$tst_sym2=K" $tst_prog | grep -q "$tst_sym2"
63if (( $? == 0 )); then
64	printf >&2 "%s=K somehow returned itself, did it become a number?\n" \
65	    "$tst_sym2"
66	tst_err=1
67fi
68
69$MDB -e "$tst_sym2::dis" $tst_prog | egrep -qi '^_007:'
70if (( $? != 0 )); then
71	printf >&2 "Failed to find expected output for %s::dis\n" "$tst_sym2"
72	tst_err=1
73fi
74
75exit $tst_err
76