[DTrace-devel] [PATCH v2 5/5] dlibs, test: reduce complexity of tests
Kris Van Hees
kris.van.hees at oracle.com
Tue Nov 7 06:58:01 UTC 2023
Some tests depended on kernel variable type information that is not
currently available when only BTF type data can be found. Use
explicit casting:
Some tests used kernel variables without needing to. Use other
sources that provide the same functionality:
Some tests should be skipped when there is no CTF archive:
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
libdtrace/io.d.in | 7 +++++--
.../assocs/err.D_OP_INCOMPAT.dupgtype.d | 6 +++---
.../assocs/err.D_OP_INCOMPAT.dupgtype.r | 2 +-
.../assocs/err.D_OP_INCOMPAT.dupgtype.r.p | 3 +++
.../assocs/err.D_OP_INCOMPAT.dupttype.d | 6 +++---
.../assocs/err.D_OP_INCOMPAT.dupttype.r | 2 +-
.../assocs/err.D_OP_INCOMPAT.dupttype.r.p | 1 +
.../tst.kernel_read_deref_indirect_str.d | 4 ++--
.../codegen/tst.kernel_read_deref_struct.d | 4 ++--
.../tst.kernel_read_index_indirect_str.d | 4 ++--
.../codegen/tst.kernel_read_indirect_scalar.d | 4 ++--
test/unittest/codegen/tst.kernel_read_str.d | 4 ++--
.../funcs/strjoin/tst.strjoin_nonDPTR.d | 2 +-
.../funcs/strtok/tst.strtok_nonDPTR.d | 6 +++---
.../funcs/substr/tst.substr_nonDPTR.d | 4 ++--
test/unittest/funcs/tst.basename_nonDPTR.d | 2 +-
test/unittest/funcs/tst.dirname_nonDPTR.d | 2 +-
test/unittest/funcs/tst.index_nonDPTR.d | 2 +-
test/unittest/funcs/tst.rindex_nonDPTR.d | 2 +-
test/unittest/funcs/tst.strchr_nonDPTR.d | 4 ++--
test/unittest/funcs/tst.subr.d | 14 +++++++-------
test/unittest/inline/tst.InlineDataAssign.d | 4 ++--
test/unittest/inline/tst.InlineExpression.d | 4 ++--
test/unittest/inline/tst.InlineTypedef.d | 4 ++--
test/unittest/lexer/tst.keyword-member.d | 16 ++++++++--------
test/unittest/options/err.ctfpath.d | 19 -------------------
test/unittest/options/err.ctfpath.r | 4 +---
test/unittest/options/err.ctfpath.sh | 18 ++++++++++++++++++
test/unittest/options/tst.ctfpath.x | 8 ++++++++
test/unittest/options/tst.modpath.x | 1 +
test/unittest/pointers/tst.GlobalVar.d | 4 ++--
test/unittest/pointers/tst.basic1.d | 4 ++--
test/unittest/pointers/tst.basic2.d | 2 +-
.../scalars/err.D_OP_INCOMPAT.dupgtype.d | 6 +++---
.../scalars/err.D_OP_INCOMPAT.dupltype.d | 6 +++---
.../scalars/err.D_OP_INCOMPAT.dupttype.d | 6 +++---
test/unittest/struct/tst.StructDataTypes.d | 4 ++--
test/unittest/trace/tst.misc.d | 4 ++--
.../tracemem/err.D_TRACEMEM_ADDR.badaddr.d | 8 +++++++-
.../tracemem/err.D_TRACEMEM_ADDR.badaddr.r | 2 +-
test/unittest/union/tst.UnionDataTypes.d | 4 ++--
41 files changed, 116 insertions(+), 97 deletions(-)
create mode 100755 test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.r.p
create mode 120000 test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.r.p
delete mode 100644 test/unittest/options/err.ctfpath.d
create mode 100755 test/unittest/options/err.ctfpath.sh
create mode 100755 test/unittest/options/tst.ctfpath.x
create mode 120000 test/unittest/options/tst.modpath.x
diff --git a/libdtrace/io.d.in b/libdtrace/io.d.in
index d34517a0..b3da5177 100644
--- a/libdtrace/io.d.in
+++ b/libdtrace/io.d.in
@@ -129,8 +129,11 @@ translator devinfo_t < struct bio *B > {
dev_major = B->__disk_chk == NULL ? 0 : getmajor(B->__bio_part_dev);
dev_minor = B->__disk_chk == NULL ? 0 : getminor(B->__bio_part_dev);
dev_instance = 0;
- dev_name = B->__disk_chk == NULL ? "nfs" : stringof(`major_names[
- getmajor(B->__bio_part_dev) % 255]->name);
+ dev_name = B->__disk_chk == NULL
+ ? "nfs"
+ : stringof(((struct blk_major_name **)`major_names)[
+ getmajor(B->__bio_part_dev) % 255
+ ]->name);
dev_statname = B->__disk_chk == NULL ? "nfs" :
B->__bio_partno == 0 ? stringof(B->__disk->disk_name) :
strjoin(stringof(B->__disk->disk_name), lltostr(B->__bio_partno));
diff --git a/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.d b/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.d
index 6ce31c38..7443dfb1 100644
--- a/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.d
+++ b/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -16,6 +16,6 @@
BEGIN
{
- x[123] = *`cad_pid;
- x[456] = `max_pfn;
+ x[123] = curthread;
+ x[456] = pid;
}
diff --git a/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.r b/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.r
index 4ebf0357..d1aa3877 100644
--- a/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.r
+++ b/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.r
@@ -1,2 +1,2 @@
-- @@stderr --
-dtrace: failed to compile script test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.d: [D_OP_INCOMPAT] line 20: operands have incompatible types: "struct pid" = "long unsigned int"
+dtrace: failed to compile script test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.d: [D_OP_INCOMPAT] line 20: operands have incompatible types:
diff --git a/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.r.p b/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.r.p
new file mode 100755
index 00000000..f22d1399
--- /dev/null
+++ b/test/unittest/assocs/err.D_OP_INCOMPAT.dupgtype.r.p
@@ -0,0 +1,3 @@
+#!/bin/sed -f
+
+s/types: .*$/types:/
diff --git a/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.d b/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.d
index 22cdee17..1e00b5b0 100644
--- a/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.d
+++ b/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -16,6 +16,6 @@
BEGIN
{
- self->x[123] = *`cad_pid;
- self->x[456] = `max_pfn;
+ self->x[123] = curthread;
+ self->x[456] = pid;
}
diff --git a/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.r b/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.r
index 623c6b8b..537d0ea3 100644
--- a/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.r
+++ b/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.r
@@ -1,2 +1,2 @@
-- @@stderr --
-dtrace: failed to compile script test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.d: [D_OP_INCOMPAT] line 20: operands have incompatible types: "struct pid" = "long unsigned int"
+dtrace: failed to compile script test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.d: [D_OP_INCOMPAT] line 20: operands have incompatible types:
diff --git a/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.r.p b/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.r.p
new file mode 120000
index 00000000..6422da01
--- /dev/null
+++ b/test/unittest/assocs/err.D_OP_INCOMPAT.dupttype.r.p
@@ -0,0 +1 @@
+err.D_OP_INCOMPAT.dupgtype.r.p
\ No newline at end of file
diff --git a/test/unittest/codegen/tst.kernel_read_deref_indirect_str.d b/test/unittest/codegen/tst.kernel_read_deref_indirect_str.d
index e20ac47b..25b6f5e7 100644
--- a/test/unittest/codegen/tst.kernel_read_deref_indirect_str.d
+++ b/test/unittest/codegen/tst.kernel_read_deref_indirect_str.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, 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.
*/
@@ -15,7 +15,7 @@
BEGIN
{
- exit(*`linux_banner == 'L' ? 0 : 1);
+ exit(*(char *)&`linux_banner == 'L' ? 0 : 1);
}
ERROR
diff --git a/test/unittest/codegen/tst.kernel_read_deref_struct.d b/test/unittest/codegen/tst.kernel_read_deref_struct.d
index 5baf604c..c8ad5d3d 100644
--- a/test/unittest/codegen/tst.kernel_read_deref_struct.d
+++ b/test/unittest/codegen/tst.kernel_read_deref_struct.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, 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.
*/
@@ -9,7 +9,7 @@
BEGIN
{
- trace(*`cad_pid);
+ trace(*(struct pid *)`cad_pid);
exit(0);
}
diff --git a/test/unittest/codegen/tst.kernel_read_index_indirect_str.d b/test/unittest/codegen/tst.kernel_read_index_indirect_str.d
index 94846e5a..1e7ade8d 100644
--- a/test/unittest/codegen/tst.kernel_read_index_indirect_str.d
+++ b/test/unittest/codegen/tst.kernel_read_index_indirect_str.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, 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.
*/
@@ -17,7 +17,7 @@ char *s;
BEGIN
{
- s = `linux_banner;
+ s = (char *)&`linux_banner;
exit(s[0] == 'L' ? 0 : 1);
}
diff --git a/test/unittest/codegen/tst.kernel_read_indirect_scalar.d b/test/unittest/codegen/tst.kernel_read_indirect_scalar.d
index 3683d4aa..5f189080 100644
--- a/test/unittest/codegen/tst.kernel_read_indirect_scalar.d
+++ b/test/unittest/codegen/tst.kernel_read_indirect_scalar.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, 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.
*/
@@ -9,7 +9,7 @@
BEGIN
{
- trace(`cad_pid->level);
+ trace(((struct pid *)`cad_pid)->level);
exit(0);
}
diff --git a/test/unittest/codegen/tst.kernel_read_str.d b/test/unittest/codegen/tst.kernel_read_str.d
index 4ff61b8c..dcdd7d42 100644
--- a/test/unittest/codegen/tst.kernel_read_str.d
+++ b/test/unittest/codegen/tst.kernel_read_str.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023, 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.
*/
@@ -9,7 +9,7 @@
BEGIN
{
- trace((string)`linux_banner);
+ trace((string)&`linux_banner);
exit(0);
}
diff --git a/test/unittest/funcs/strjoin/tst.strjoin_nonDPTR.d b/test/unittest/funcs/strjoin/tst.strjoin_nonDPTR.d
index bbd79d1c..a1816f97 100644
--- a/test/unittest/funcs/strjoin/tst.strjoin_nonDPTR.d
+++ b/test/unittest/funcs/strjoin/tst.strjoin_nonDPTR.d
@@ -10,7 +10,7 @@
BEGIN
{
- printf("|%s|\n", strjoin(`linux_banner, `linux_banner));
+ printf("|%s|\n", strjoin((char *)&`linux_banner, (char *)&`linux_banner));
exit(0);
}
diff --git a/test/unittest/funcs/strtok/tst.strtok_nonDPTR.d b/test/unittest/funcs/strtok/tst.strtok_nonDPTR.d
index 00753e59..191b71a4 100644
--- a/test/unittest/funcs/strtok/tst.strtok_nonDPTR.d
+++ b/test/unittest/funcs/strtok/tst.strtok_nonDPTR.d
@@ -10,10 +10,10 @@
BEGIN
{
- printf("|%s|\n", strtok(`linux_banner, " "));
+ printf("|%s|\n", strtok((char *)&`linux_banner, " "));
printf("|%s|\n", strtok(NULL, " "));
- printf("|%s|\n", strtok("@@@@@ !!!!!", `linux_banner));
- printf("|%s|\n", strtok(NULL, `linux_banner));
+ printf("|%s|\n", strtok("@@@@@ !!!!!", (char *)&`linux_banner));
+ printf("|%s|\n", strtok(NULL, (char *)&`linux_banner));
exit(0);
}
diff --git a/test/unittest/funcs/substr/tst.substr_nonDPTR.d b/test/unittest/funcs/substr/tst.substr_nonDPTR.d
index d85800f3..9d847ab6 100644
--- a/test/unittest/funcs/substr/tst.substr_nonDPTR.d
+++ b/test/unittest/funcs/substr/tst.substr_nonDPTR.d
@@ -10,8 +10,8 @@
BEGIN
{
- printf("|%s|\n", substr(`linux_banner, 1));
- printf("|%s|\n", substr(`linux_banner, 1, 4));
+ printf("|%s|\n", substr((char *)&`linux_banner, 1));
+ printf("|%s|\n", substr((char *)&`linux_banner, 1, 4));
exit(0);
}
diff --git a/test/unittest/funcs/tst.basename_nonDPTR.d b/test/unittest/funcs/tst.basename_nonDPTR.d
index 3e00ceeb..4f93685f 100644
--- a/test/unittest/funcs/tst.basename_nonDPTR.d
+++ b/test/unittest/funcs/tst.basename_nonDPTR.d
@@ -10,7 +10,7 @@
BEGIN
{
- printf("|%s|\n", basename(`linux_banner));
+ printf("|%s|\n", basename((char *)&`linux_banner));
exit(0);
}
diff --git a/test/unittest/funcs/tst.dirname_nonDPTR.d b/test/unittest/funcs/tst.dirname_nonDPTR.d
index 8d19eb5a..8a60cc98 100644
--- a/test/unittest/funcs/tst.dirname_nonDPTR.d
+++ b/test/unittest/funcs/tst.dirname_nonDPTR.d
@@ -10,7 +10,7 @@
BEGIN
{
- printf("|%s|\n", dirname(`linux_banner));
+ printf("|%s|\n", dirname((char *)&`linux_banner));
exit(0);
}
diff --git a/test/unittest/funcs/tst.index_nonDPTR.d b/test/unittest/funcs/tst.index_nonDPTR.d
index b3a08266..cf7e762c 100644
--- a/test/unittest/funcs/tst.index_nonDPTR.d
+++ b/test/unittest/funcs/tst.index_nonDPTR.d
@@ -10,7 +10,7 @@
BEGIN
{
- printf("index is %d, should be 0\n", index(`linux_banner, `linux_banner));
+ printf("index is %d, should be 0\n", index((char *)&`linux_banner, (char *)&`linux_banner));
exit(0);
}
diff --git a/test/unittest/funcs/tst.rindex_nonDPTR.d b/test/unittest/funcs/tst.rindex_nonDPTR.d
index 974b35de..ad14e357 100644
--- a/test/unittest/funcs/tst.rindex_nonDPTR.d
+++ b/test/unittest/funcs/tst.rindex_nonDPTR.d
@@ -10,7 +10,7 @@
BEGIN
{
- printf("rindex is %d, should be 0\n", rindex(`linux_banner, `linux_banner));
+ printf("rindex is %d, should be 0\n", rindex((char *)&`linux_banner, (char *)&`linux_banner));
exit(0);
}
diff --git a/test/unittest/funcs/tst.strchr_nonDPTR.d b/test/unittest/funcs/tst.strchr_nonDPTR.d
index 726a1a3c..b3dacef8 100644
--- a/test/unittest/funcs/tst.strchr_nonDPTR.d
+++ b/test/unittest/funcs/tst.strchr_nonDPTR.d
@@ -10,8 +10,8 @@
BEGIN
{
- printf("|%s|\n", strchr(`linux_banner, 'x'));
- printf("|%s|\n", strrchr(`linux_banner, 'u'));
+ printf("|%s|\n", strchr((char *)&`linux_banner, 'x'));
+ printf("|%s|\n", strrchr((char *)&`linux_banner, 'u'));
exit(0);
}
diff --git a/test/unittest/funcs/tst.subr.d b/test/unittest/funcs/tst.subr.d
index 4054036b..9f7203c0 100644
--- a/test/unittest/funcs/tst.subr.d
+++ b/test/unittest/funcs/tst.subr.d
@@ -39,13 +39,13 @@
#define NUM_UNIMPLEMENTED 7
INTFUNC(rand())
-INTFUNC(mutex_owned(&`bpf_verifier_lock))
-INTFUNC(mutex_owner(&`bpf_verifier_lock))
-INTFUNC(mutex_type_adaptive(&`bpf_verifier_lock))
-INTFUNC(mutex_type_spin(&`bpf_verifier_lock))
-INTFUNC(rw_read_held(&`tasklist_lock))
-INTFUNC(rw_write_held(&`tasklist_lock))
-INTFUNC(rw_iswriter(&`tasklist_lock))
+INTFUNC(mutex_owned((struct mutex *)&`bpf_verifier_lock))
+INTFUNC(mutex_owner((struct mutex *)&`bpf_verifier_lock))
+INTFUNC(mutex_type_adaptive((struct mutex *)&`bpf_verifier_lock))
+INTFUNC(mutex_type_spin((struct mutex *)&`bpf_verifier_lock))
+INTFUNC(rw_read_held((rwlock_t *)&`tasklist_lock))
+INTFUNC(rw_write_held((rwlock_t *)&`tasklist_lock))
+INTFUNC(rw_iswriter((rwlock_t *)&`tasklist_lock))
INTFUNC(copyin(0, 1))
STRFUNC(copyinstr(0, 1))
INTFUNC(speculation())
diff --git a/test/unittest/inline/tst.InlineDataAssign.d b/test/unittest/inline/tst.InlineDataAssign.d
index f7bb071c..a0ce2bfe 100644
--- a/test/unittest/inline/tst.InlineDataAssign.d
+++ b/test/unittest/inline/tst.InlineDataAssign.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -39,7 +39,7 @@ inline double new_double = 2.34567890;
inline long double new_long_double = 3.567890123;
*/
-inline unsigned long * pointer = &`max_pfn;
+inline unsigned long * pointer = (unsigned long *)&`max_pfn;
BEGIN
{
diff --git a/test/unittest/inline/tst.InlineExpression.d b/test/unittest/inline/tst.InlineExpression.d
index de215ed2..8ba57e36 100644
--- a/test/unittest/inline/tst.InlineExpression.d
+++ b/test/unittest/inline/tst.InlineExpression.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -41,7 +41,7 @@ inline double new_double = 2.34567890;
inline long double new_long_double = 3.567890123;
*/
-inline unsigned long * pointer = &`max_pfn;
+inline unsigned long * pointer = (unsigned long *)&`max_pfn;
inline int result = 3 > 2 ? 3 : 2;
BEGIN
diff --git a/test/unittest/inline/tst.InlineTypedef.d b/test/unittest/inline/tst.InlineTypedef.d
index f348cca1..fc2ca1ec 100644
--- a/test/unittest/inline/tst.InlineTypedef.d
+++ b/test/unittest/inline/tst.InlineTypedef.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -22,7 +22,7 @@ typedef char new_char;
inline new_char char_var = 'c';
typedef unsigned long * pointer;
-inline pointer p = &`max_pfn;
+inline pointer p = (pointer)&`max_pfn;
BEGIN
{
diff --git a/test/unittest/lexer/tst.keyword-member.d b/test/unittest/lexer/tst.keyword-member.d
index 8137f97f..0c3650e3 100644
--- a/test/unittest/lexer/tst.keyword-member.d
+++ b/test/unittest/lexer/tst.keyword-member.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2023, 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.
*/
@@ -13,13 +13,13 @@
BEGIN
{
- printf("%p\n", &`cgrp_dfl_root.cgrp.self);
- printf("%p\n", &`cgrp_dfl_root.cgrp.self.cgroup->self);
- printf("%p\n", `cgrp_dfl_root.cgrp.self.cgroup->self.cgroup);
- printf("%p\n", &`cgrp_dfl_root.cgrp./* foo */self.cgroup->self);
- printf("%p\n", `cgrp_dfl_root.cgrp.self.cgroup->/* foo */self.cgroup);
- printf("%p\n", &`cgrp_dfl_root.cgrp.self/* foo */.cgroup->self);
- printf("%p\n", `cgrp_dfl_root.cgrp.self.cgroup->self/* foo */.cgroup);
+ printf("%p\n", &(*(struct cgroup_root *)&`cgrp_dfl_root).cgrp.self);
+ printf("%p\n", &(*(struct cgroup_root *)&`cgrp_dfl_root).cgrp.self.cgroup->self);
+ printf("%p\n", (*(struct cgroup_root *)&`cgrp_dfl_root).cgrp.self.cgroup->self.cgroup);
+ printf("%p\n", &(*(struct cgroup_root *)&`cgrp_dfl_root).cgrp./* foo */self.cgroup->self);
+ printf("%p\n", (*(struct cgroup_root *)&`cgrp_dfl_root).cgrp.self.cgroup->/* foo */self.cgroup);
+ printf("%p\n", &(*(struct cgroup_root *)&`cgrp_dfl_root).cgrp.self/* foo */.cgroup->self);
+ printf("%p\n", (*(struct cgroup_root *)&`cgrp_dfl_root).cgrp.self.cgroup->self/* foo */.cgroup);
exit(0);
}
diff --git a/test/unittest/options/err.ctfpath.d b/test/unittest/options/err.ctfpath.d
deleted file mode 100644
index ce3e1a27..00000000
--- a/test/unittest/options/err.ctfpath.d
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2022, 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.
- */
-
-/*
- * ASSERTION: The -xctfpath option overrides the default vmlinux CTF archive.
- *
- * SECTION: Options and Tunables/Consumer Options
- */
-
-/* @@runtest-opts: -xctfpath=/dev/null */
-
-BEGIN
-{
- exit(0);
-}
diff --git a/test/unittest/options/err.ctfpath.r b/test/unittest/options/err.ctfpath.r
index 59bcb27e..92509758 100644
--- a/test/unittest/options/err.ctfpath.r
+++ b/test/unittest/options/err.ctfpath.r
@@ -1,3 +1 @@
--- @@stderr --
-dtrace: script 'test/unittest/options/err.ctfpath.d' matched 1 probe
-dtrace: could not enable tracing: Module does not contain any CTF data
+Cannot open CTF archive /dev/null: File is not in CTF or ELF format.; trying BTF.
diff --git a/test/unittest/options/err.ctfpath.sh b/test/unittest/options/err.ctfpath.sh
new file mode 100755
index 00000000..d0898729
--- /dev/null
+++ b/test/unittest/options/err.ctfpath.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2023, 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.
+#
+
+dtrace=$1
+
+$dtrace $dt_flags -xdebug -xctfpath=/dev/null -n 'BEGIN { exit(0); }' |&
+ awk '/Cannot open CTF archive \/dev\/null/ {
+ sub(/^[^:]+: /, "");
+ print;
+ exit(1);
+ }'
+
+exit $?
diff --git a/test/unittest/options/tst.ctfpath.x b/test/unittest/options/tst.ctfpath.x
new file mode 100755
index 00000000..3bf92d74
--- /dev/null
+++ b/test/unittest/options/tst.ctfpath.x
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+if [ -r /lib/modules/$(uname -r)/kernel/vmlinux.ctfa ]; then
+ exit 0
+else
+ echo "No CTF archive found for the kernel."
+ exit 2
+fi
diff --git a/test/unittest/options/tst.modpath.x b/test/unittest/options/tst.modpath.x
new file mode 120000
index 00000000..df5695cd
--- /dev/null
+++ b/test/unittest/options/tst.modpath.x
@@ -0,0 +1 @@
+tst.ctfpath.x
\ No newline at end of file
diff --git a/test/unittest/pointers/tst.GlobalVar.d b/test/unittest/pointers/tst.GlobalVar.d
index 33af2026..35499245 100644
--- a/test/unittest/pointers/tst.GlobalVar.d
+++ b/test/unittest/pointers/tst.GlobalVar.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -19,7 +19,7 @@
BEGIN
{
i = 0;
- pfnAddress = &`max_pfn;
+ pfnAddress = (unsigned long *)&`max_pfn;
pfnValue = *pfnAddress;
printf("Address of max_pfn: %x\n", (int)pfnAddress);
printf("Value of max_pfn: %d\n", pfnValue);
diff --git a/test/unittest/pointers/tst.basic1.d b/test/unittest/pointers/tst.basic1.d
index 75ec0489..f4e6ad0f 100644
--- a/test/unittest/pointers/tst.basic1.d
+++ b/test/unittest/pointers/tst.basic1.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -18,7 +18,7 @@
BEGIN
{
- pfnAddress = &`max_pfn;
+ pfnAddress = (unsigned long *)&`max_pfn;
pfnValue = *pfnAddress;
printf("Address of max_pfn: %x\n", (int)pfnAddress);
printf("Value of max_pfn: %d\n", pfnValue);
diff --git a/test/unittest/pointers/tst.basic2.d b/test/unittest/pointers/tst.basic2.d
index c17f9251..f026a10d 100644
--- a/test/unittest/pointers/tst.basic2.d
+++ b/test/unittest/pointers/tst.basic2.d
@@ -18,7 +18,7 @@
BEGIN
{
- assoc_array["pfnAddress"] = &`max_pfn;
+ assoc_array["pfnAddress"] = (unsigned long *)&`max_pfn;
pfnValue = *(assoc_array["pfnAddress"]);
printf("Address of max_pfn: %x\n", (int)assoc_array["pfnAddress"]);
printf("Value of max_pfn: %d\n", pfnValue);
diff --git a/test/unittest/scalars/err.D_OP_INCOMPAT.dupgtype.d b/test/unittest/scalars/err.D_OP_INCOMPAT.dupgtype.d
index 5a2f51bc..fd4452c7 100644
--- a/test/unittest/scalars/err.D_OP_INCOMPAT.dupgtype.d
+++ b/test/unittest/scalars/err.D_OP_INCOMPAT.dupgtype.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -15,6 +15,6 @@
BEGIN
{
- x = *`cad_pid;
- x = `max_pfn;
+ x = curthread;
+ x = pid;
}
diff --git a/test/unittest/scalars/err.D_OP_INCOMPAT.dupltype.d b/test/unittest/scalars/err.D_OP_INCOMPAT.dupltype.d
index f89caac5..713c1898 100644
--- a/test/unittest/scalars/err.D_OP_INCOMPAT.dupltype.d
+++ b/test/unittest/scalars/err.D_OP_INCOMPAT.dupltype.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -15,6 +15,6 @@
BEGIN
{
- this->x = *`cad_pid;
- this->x = `max_pfn;
+ this->x = curthread;
+ this->x = pid;
}
diff --git a/test/unittest/scalars/err.D_OP_INCOMPAT.dupttype.d b/test/unittest/scalars/err.D_OP_INCOMPAT.dupttype.d
index 30ec1bbc..23a7d440 100644
--- a/test/unittest/scalars/err.D_OP_INCOMPAT.dupttype.d
+++ b/test/unittest/scalars/err.D_OP_INCOMPAT.dupttype.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -16,6 +16,6 @@
BEGIN
{
- self->x = *`cad_pid;
- self->x = `max_pfn;
+ self->x = curthread;
+ self->x = pid;
}
diff --git a/test/unittest/struct/tst.StructDataTypes.d b/test/unittest/struct/tst.StructDataTypes.d
index 70a66ec8..abf0e90f 100644
--- a/test/unittest/struct/tst.StructDataTypes.d
+++ b/test/unittest/struct/tst.StructDataTypes.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -93,7 +93,7 @@ BEGIN
var.new_string = "hello";
*/
- var.pointer = &`max_pfn;
+ var.pointer = (unsigned long *)&`max_pfn;
var.new_struct.ch = 'c';
var.new_struct.in = 4;
diff --git a/test/unittest/trace/tst.misc.d b/test/unittest/trace/tst.misc.d
index 1fb0ea76..1075c500 100644
--- a/test/unittest/trace/tst.misc.d
+++ b/test/unittest/trace/tst.misc.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -31,7 +31,7 @@ tick-1
trace(x++); /* DT_TYPE_INT (derived) */
trace(timestamp); /* DT_TYPE_INT (variable) */
trace(`max_pfn); /* CTF type (by value) */
- trace(*`linux_banner); /* CTF type (by ref) */
+ trace(*&`linux_banner); /* CTF type (by ref) */
i++;
}
diff --git a/test/unittest/tracemem/err.D_TRACEMEM_ADDR.badaddr.d b/test/unittest/tracemem/err.D_TRACEMEM_ADDR.badaddr.d
index 0ad7d4e4..478a0f47 100644
--- a/test/unittest/tracemem/err.D_TRACEMEM_ADDR.badaddr.d
+++ b/test/unittest/tracemem/err.D_TRACEMEM_ADDR.badaddr.d
@@ -14,5 +14,11 @@
BEGIN
{
- tracemem(`init_mm, 123);
+ tracemem(*curthread, 123);
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
}
diff --git a/test/unittest/tracemem/err.D_TRACEMEM_ADDR.badaddr.r b/test/unittest/tracemem/err.D_TRACEMEM_ADDR.badaddr.r
index 3c2c9ca0..01561e9d 100644
--- a/test/unittest/tracemem/err.D_TRACEMEM_ADDR.badaddr.r
+++ b/test/unittest/tracemem/err.D_TRACEMEM_ADDR.badaddr.r
@@ -1,4 +1,4 @@
-- @@stderr --
dtrace: failed to compile script test/unittest/tracemem/err.D_TRACEMEM_ADDR.badaddr.d: [D_TRACEMEM_ADDR] line 17: tracemem( ) argument #1 is incompatible with prototype:
prototype: pointer or integer
- argument: struct mm_struct
+ argument: struct task_struct
diff --git a/test/unittest/union/tst.UnionDataTypes.d b/test/unittest/union/tst.UnionDataTypes.d
index aa8cc5ca..035706ef 100644
--- a/test/unittest/union/tst.UnionDataTypes.d
+++ b/test/unittest/union/tst.UnionDataTypes.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2023, 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.
*/
@@ -95,7 +95,7 @@ BEGIN
var.new_string = "hello";
*/
- var.pointer = &`max_pfn;
+ var.pointer = (unsigned long *)&`max_pfn;
var.new_struct.ch = 'c';
var.new_struct.in = 4;
--
2.40.1
More information about the DTrace-devel
mailing list