From: Kris Van Hees <kris.van.hees@oracle.com>
To: Eugene Loh <eugene.loh@oracle.com>
Cc: Kris Van Hees <kris.van.hees@oracle.com>,
dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH 4/4] test: Add test for predefined preprocessor definitions
Date: Tue, 18 Mar 2025 16:42:58 -0400 [thread overview]
Message-ID: <Z9na0viYV3SzQZO3@oracle.com> (raw)
In-Reply-To: <44b61914-f25d-c89c-5d9e-085bbab2fdb6@oracle.com>
On Tue, Mar 18, 2025 at 04:35:08PM -0400, Eugene Loh wrote:
> On 3/18/25 15:18, Kris Van Hees wrote:
>
> > On Sat, Feb 08, 2025 at 02:06:22PM -0500, eugene.loh@oracle.com wrote:
> > > From: Eugene Loh <eugene.loh@oracle.com>
> > >
> > > Orabug: 28763074
> > > Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> > Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
> >
> > ... and incidentally, should we add defines with ORCL instead of SUNW
> > (but keep SUNW variants for backwards compatibility)? Or some other
> > forms that do not include SUNW. Things like __DTRACE?
>
> Separate patch, right? And, we need to coordinate documentation.
Yes, definitely separate patch.
> > > ---
> > > COMMANDLINE-OPTIONS | 10 +-
> > > test/unittest/preprocessor/tst.predefined.r | 1 +
> > > test/unittest/preprocessor/tst.predefined.sh | 119 +++++++++++++++++++
> > > 3 files changed, 125 insertions(+), 5 deletions(-)
> > > create mode 100644 test/unittest/preprocessor/tst.predefined.r
> > > create mode 100755 test/unittest/preprocessor/tst.predefined.sh
> > >
> > > diff --git a/COMMANDLINE-OPTIONS b/COMMANDLINE-OPTIONS
> > > index 40561af91..73be89b1f 100644
> > > --- a/COMMANDLINE-OPTIONS
> > > +++ b/COMMANDLINE-OPTIONS
> > > @@ -321,12 +321,12 @@ definitions are always specified and valid in all modes:
> > > * __sparcv9 (on SPARC® systems only when 64???bit programs are compiled)
> > > * __i386 (on x86 systems only when 32???bit programs are compiled)
> > > * __amd64 (on x86 systems only when 64???bit programs are compiled)
> > > - * _`uname -s` (for example, __Linux)
> > > + * __`uname -s` (for example, __Linux)
> > > * __SUNW_D=1
> > > - * _SUNW_D_VERSION=0x_MMmmmuuu (where MM is the Major release value
> > > - in hexadecimal, mmm is the Minor release value in hexadecimal,
> > > - and uuu is the Micro release value in hexadecimal; see Chapter
> > > - 41, Versioning for more information about DTrace versioning)
> > > + * _SUNW_D_VERSION=(MM << 24 | mmm << 12 | uuu), where
> > > + MM is the Major release value
> > > + mmm is the Minor release value
> > > + uuu is the Micro release value
> > > -Z
> > > Permit probe descriptions that match zero probes. If the -Z option is
> > > diff --git a/test/unittest/preprocessor/tst.predefined.r b/test/unittest/preprocessor/tst.predefined.r
> > > new file mode 100644
> > > index 000000000..2e9ba477f
> > > --- /dev/null
> > > +++ b/test/unittest/preprocessor/tst.predefined.r
> > > @@ -0,0 +1 @@
> > > +success
> > > diff --git a/test/unittest/preprocessor/tst.predefined.sh b/test/unittest/preprocessor/tst.predefined.sh
> > > new file mode 100755
> > > index 000000000..79caf17ac
> > > --- /dev/null
> > > +++ b/test/unittest/preprocessor/tst.predefined.sh
> > > @@ -0,0 +1,119 @@
> > > +#!/bin/bash
> > > +#
> > > +# Oracle Linux DTrace.
> > > +# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
> > > +# Licensed under the Universal Permissive License v 1.0 as shown at
> > > +# http://oss.oracle.com/licenses/upl.
> > > +#
> > > +# Confirm preprocessor pre-definitions.
> > > +
> > > +dtrace=$1
> > > +
> > > +DIRNAME=$tmpdir/predefined.$$.$RANDOM
> > > +mkdir -p $DIRNAME
> > > +cd $DIRNAME
> > > +
> > > +# Arg 1 is macro that we check is defined.
> > > +
> > > +function check_defined() {
> > > + # Add to script: #ifdef is okay, else is ERROR.
> > > + echo '#ifdef' $1 >> D.d
> > > + echo 'printf("'$1' okay\n");' >> D.d
> > > + echo '#else' >> D.d
> > > + echo 'printf("ERROR! missing '$1'\n");' >> D.d
> > > + echo '#endif' >> D.d
> > > +
> > > + # Add to check file: expect "okay" message.
> > > + echo $1 okay >> chk.txt
> > > +}
> > > +
> > > +# Arg 1 is macro whose value we check to be arg 2.
> > > +
> > > +function check_value() {
> > > + # Add to script: print value.
> > > + echo 'printf("'$1'=%x\n", '$1');' >> D.d
> > > +
> > > + # Add to check file: expected value.
> > > + echo $1=$2 >> chk.txt
> > > +}
> > > +
> > > +# Arg 1 is macro that we check is not defined.
> > > +
> > > +function check_undef() {
> > > + # Add to script: #ifdef is ERROR, else is okay.
> > > + echo '#ifdef' $1 >> D.d
> > > + echo 'printf("ERROR! found '$1'\n");' >> D.d
> > > + echo '#else' >> D.d
> > > + echo 'printf("missing '$1' is okay\n");' >> D.d
> > > + echo '#endif' >> D.d
> > > +
> > > + # Add to check file: expect "okay" message.
> > > + echo missing $1 is okay >> chk.txt
> > > +}
> > > +
> > > +# Construct version string (major, minor, micro).
> > > +
> > > +read MM mmm uuu <<< `dtrace -vV | awk '/^This is DTrace / { gsub("\\\.", " "); print $(NF-2), $(NF-1), $NF }'`
> > > +vers=`printf "%x" $(($MM << 24 | $mmm << 12 | $uuu))`
> > > +
> > > +# Start setting up the D script.
> > > +
> > > +echo 'BEGIN {' > D.d
> > > +
> > > +# Check for the preprocessor definitions of COMMANDLINE-OPTIONS.
> > > +
> > > +check_defined __linux
> > > +check_defined __unix
> > > +check_defined __SVR4
> > > +if [ `uname -m` == x86_64 ]; then
> > > +check_defined __amd64
> > > +else
> > > +check_undef __amd64
> > > +fi
> > > +check_defined __`uname -s`
> > > +check_value __SUNW_D 1
> > > +check_value __SUNW_D_VERSION $vers
> > > +
> > > +# Confirm other preprocessor definitions.
> > > +
> > > +check_defined __SUNW_D_64
> > > +
> > > +# Confirm that __GNUC__ is not present.
> > > +
> > > +check_undef __GNUC__
> > > +
> > > +# Finish setting up the D script.
> > > +
> > > +echo 'exit(0); }' >> D.d
> > > +echo >> chk.txt
> > > +
> > > +# Run the D script.
> > > +
> > > +$dtrace $dt_flags -qCs D.d -o out.txt
> > > +if [ $? -ne 0 ]; then
> > > + echo ERROR: DTrace failed
> > > + echo "==== D.d"
> > > + cat D.d
> > > + echo "==== out.txt"
> > > + cat out.txt
> > > + exit 1
> > > +fi
> > > +
> > > +# Check.
> > > +
> > > +if ! diff -q chk.txt out.txt; then
> > > + echo ERROR output disagrees
> > > + echo === expect ===
> > > + cat chk.txt
> > > + echo === actual ===
> > > + cat out.txt
> > > + echo === diff ===
> > > + diff chk.txt out.txt
> > > + exit 1
> > > +fi
> > > +
> > > +# Indicate success.
> > > +
> > > +echo success
> > > +
> > > +exit 0
> > > --
> > > 2.43.5
> > >
next prev parent reply other threads:[~2025-03-18 20:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-08 19:06 [PATCH 1/4] Rename _DTRACE_VERSION eugene.loh
2025-02-08 19:06 ` [PATCH 2/4] Eliminate DT_VERS_LATEST eugene.loh
2025-02-27 16:40 ` Kris Van Hees
2025-02-27 16:57 ` [DTrace-devel] " Kris Van Hees
2025-02-28 3:19 ` Kris Van Hees
2025-02-08 19:06 ` [PATCH 3/4] Sync up the version numbers eugene.loh
2025-02-08 19:06 ` [PATCH 4/4] test: Add test for predefined preprocessor definitions eugene.loh
2025-03-18 19:18 ` Kris Van Hees
2025-03-18 20:35 ` Eugene Loh
2025-03-18 20:42 ` Kris Van Hees [this message]
2025-02-27 16:27 ` [PATCH 1/4] Rename _DTRACE_VERSION Kris Van Hees
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z9na0viYV3SzQZO3@oracle.com \
--to=kris.van.hees@oracle.com \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
--cc=eugene.loh@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox