summaryrefslogtreecommitdiff
path: root/testsuite/ltrace.main/system_call_params.exp
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/ltrace.main/system_call_params.exp')
-rw-r--r--testsuite/ltrace.main/system_call_params.exp71
1 files changed, 71 insertions, 0 deletions
diff --git a/testsuite/ltrace.main/system_call_params.exp b/testsuite/ltrace.main/system_call_params.exp
new file mode 100644
index 0000000..2ccf840
--- /dev/null
+++ b/testsuite/ltrace.main/system_call_params.exp
@@ -0,0 +1,71 @@
+# This file is part of ltrace.
+# Copyright (C) 2013, 2014 Petr Machata, Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+set bin [ltraceCompile {} [ltraceSource c {
+ #define _GNU_SOURCE
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/syscall.h> /* For SYS_xxx definitions */
+
+ #ifndef SYS_open
+ # if defined(__aarch64__)
+ # /* Linux doesn't actually implement SYS_open on AArch64, but for merely
+ # * recording the syscall, it's fine. */
+ # define SYS_open 1024
+ # else
+ # error SYS_open not available.
+ # endif
+ #endif
+
+ int main(void) {
+ syscall(SYS_open, "/some/path", O_RDONLY);
+ write(1, "something", 10);
+ mount("source", "target", "filesystemtype", 0, 0);
+ }
+}]]
+
+set dir [ltraceDir]
+set conf [ltraceNamedSource "$dir/syscalls.conf" {
+ int open(string, int);
+ long write(int, string[arg3], ulong);
+ int mount(string, string, string, ulong, addr);
+}]
+
+# When given the file directly via -F, ltrace should not use it for
+# formatting system calls. The reason is that libraries are generally
+# allowed to have functions with the same names as system calls
+# (there's no interference between those two). In particular,
+# readdir@SYS has a different prototype from readdir@libc. If a -F
+# somelib.conf is passed, and syscalls.conf is not available, or
+# doesn't list readdir, that would be taken from somelib.conf with a
+# wrong prototype.
+
+ltraceMatch1 [ltraceRun -L -S -F $conf -- $bin] {^open@SYS\("/some/path"} == 0
+
+# On the other hand, if -F somedir/ is given, we want to accept
+# syscalls.conf found there.
+
+ltraceMatch [ltraceRun -L -S -F $dir -- $bin] {
+ {{^open@SYS\("/some/path"} == 1}
+ {{^write@SYS\(1, "something", 10\)} == 1}
+ {{^mount@SYS\("source", "target", "filesystemtype"} == 1}
+}
+
+ltraceDone