|
|
920d6f |
From 4724bd5a4a19db117a1d280b9d1a3508fd4e03fa Mon Sep 17 00:00:00 2001
|
|
|
920d6f |
From: Petr Machata <pmachata@redhat.com>
|
|
|
920d6f |
Date: Wed, 8 Apr 2015 07:11:52 -0400
|
|
|
920d6f |
Subject: [PATCH 1/2] Convert main-threaded test case to new style
|
|
|
920d6f |
|
|
|
920d6f |
---
|
|
|
920d6f |
testsuite/ltrace.main/Makefile.am | 4 +-
|
|
|
920d6f |
testsuite/ltrace.main/main-threaded.c | 30 ----------
|
|
|
920d6f |
testsuite/ltrace.main/main-threaded.exp | 103 ++++++++++++++++++++------------
|
|
|
920d6f |
3 files changed, 66 insertions(+), 71 deletions(-)
|
|
|
920d6f |
delete mode 100644 testsuite/ltrace.main/main-threaded.c
|
|
|
920d6f |
|
|
|
920d6f |
diff --git a/testsuite/ltrace.main/Makefile.am b/testsuite/ltrace.main/Makefile.am
|
|
|
920d6f |
index 23ab8ab..06ad613 100644
|
|
|
920d6f |
--- a/testsuite/ltrace.main/Makefile.am
|
|
|
920d6f |
+++ b/testsuite/ltrace.main/Makefile.am
|
|
|
920d6f |
@@ -1,4 +1,4 @@
|
|
|
920d6f |
-# Copyright (C) 1992 - 2001, 2012, 2013 Free Software Foundation, Inc.
|
|
|
920d6f |
+# Copyright (C) 1992 - 2001, 2012, 2013, 2015 Free Software Foundation, Inc.
|
|
|
920d6f |
#
|
|
|
920d6f |
# This program is free software; you can redistribute it and/or modify
|
|
|
920d6f |
# it under the terms of the GNU General Public License as published by
|
|
|
920d6f |
@@ -17,7 +17,7 @@
|
|
|
920d6f |
|
|
|
920d6f |
EXTRA_DIST = branch_func.c branch_func.exp filters.exp hello-vfork.c \
|
|
|
920d6f |
hello-vfork.exp main.c main.exp main-internal.exp main-lib.c \
|
|
|
920d6f |
- main-threaded.c main-threaded.exp main-vfork.c main-vfork.exp \
|
|
|
920d6f |
+ main-threaded.exp main-vfork.c main-vfork.exp \
|
|
|
920d6f |
parameters.c parameters.conf parameters.exp parameters-lib.c \
|
|
|
920d6f |
parameters2.exp parameters3.exp signals.c signals.exp \
|
|
|
920d6f |
system_calls.c system_calls.exp system_call_params.exp
|
|
|
920d6f |
diff --git a/testsuite/ltrace.main/main-threaded.c b/testsuite/ltrace.main/main-threaded.c
|
|
|
920d6f |
deleted file mode 100644
|
|
|
920d6f |
index 2992d1e..0000000
|
|
|
920d6f |
--- a/testsuite/ltrace.main/main-threaded.c
|
|
|
920d6f |
+++ /dev/null
|
|
|
920d6f |
@@ -1,29 +0,0 @@
|
|
|
920d6f |
-#include <pthread.h>
|
|
|
920d6f |
-
|
|
|
920d6f |
-extern void print (char *);
|
|
|
920d6f |
-
|
|
|
920d6f |
-#define PRINT_LOOP 10
|
|
|
920d6f |
-
|
|
|
920d6f |
-void *
|
|
|
920d6f |
-th_main (void *arg)
|
|
|
920d6f |
-{
|
|
|
920d6f |
- int i;
|
|
|
920d6f |
- for (i=0; i
|
|
|
920d6f |
- print (arg);
|
|
|
920d6f |
-}
|
|
|
920d6f |
-
|
|
|
920d6f |
-int
|
|
|
920d6f |
-main ()
|
|
|
920d6f |
-{
|
|
|
920d6f |
- pthread_t thread1;
|
|
|
920d6f |
- pthread_t thread2;
|
|
|
920d6f |
- pthread_t thread3;
|
|
|
920d6f |
- pthread_create (&thread1, NULL, th_main, "aaa");
|
|
|
920d6f |
- pthread_create (&thread2, NULL, th_main, "bbb");
|
|
|
920d6f |
- pthread_create (&thread3, NULL, th_main, "ccc");
|
|
|
920d6f |
- pthread_join (thread1, NULL);
|
|
|
920d6f |
- pthread_join (thread2, NULL);
|
|
|
920d6f |
- pthread_join (thread3, NULL);
|
|
|
920d6f |
- return 0;
|
|
|
920d6f |
-}
|
|
|
920d6f |
-
|
|
|
920d6f |
diff --git a/testsuite/ltrace.main/main-threaded.exp b/testsuite/ltrace.main/main-threaded.exp
|
|
|
920d6f |
index 4d5f478..cead82d 100644
|
|
|
920d6f |
--- a/testsuite/ltrace.main/main-threaded.exp
|
|
|
920d6f |
+++ b/testsuite/ltrace.main/main-threaded.exp
|
|
|
920d6f |
@@ -1,39 +1,64 @@
|
|
|
920d6f |
-# This file was written by Yao Qi <qiyao@cn.ibm.com>.
|
|
|
920d6f |
+# This file is part of ltrace.
|
|
|
920d6f |
+# Copyright (C) 2011, 2015 Petr Machata, Red Hat Inc.
|
|
|
920d6f |
+# Copyright (C) 2006 Yao Qi <qiyao@cn.ibm.com>.
|
|
|
920d6f |
+#
|
|
|
920d6f |
+# This program is free software; you can redistribute it and/or
|
|
|
920d6f |
+# modify it under the terms of the GNU General Public License as
|
|
|
920d6f |
+# published by the Free Software Foundation; either version 2 of the
|
|
|
920d6f |
+# License, or (at your option) any later version.
|
|
|
920d6f |
+#
|
|
|
920d6f |
+# This program is distributed in the hope that it will be useful, but
|
|
|
920d6f |
+# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
920d6f |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
920d6f |
+# General Public License for more details.
|
|
|
920d6f |
+#
|
|
|
920d6f |
+# You should have received a copy of the GNU General Public License
|
|
|
920d6f |
+# along with this program; if not, write to the Free Software
|
|
|
920d6f |
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
920d6f |
+# 02110-1301 USA
|
|
|
920d6f |
+
|
|
|
920d6f |
+set libprint [ltraceCompile libprint.so [ltraceSource c {
|
|
|
920d6f |
+ #include<stdio.h>
|
|
|
920d6f |
+
|
|
|
920d6f |
+ void
|
|
|
920d6f |
+ print(char* s)
|
|
|
920d6f |
+ {
|
|
|
920d6f |
+ printf("%s\n",s);
|
|
|
920d6f |
+ }
|
|
|
920d6f |
+}]]
|
|
|
920d6f |
+
|
|
|
920d6f |
+set bin [ltraceCompile {} $libprint -lpthread [ltraceSource c {
|
|
|
920d6f |
+ #include <pthread.h>
|
|
|
920d6f |
+
|
|
|
920d6f |
+ extern void print (char *);
|
|
|
920d6f |
+
|
|
|
920d6f |
+ #define PRINT_LOOP 10
|
|
|
920d6f |
+
|
|
|
920d6f |
+ void *
|
|
|
920d6f |
+ th_main (void *arg)
|
|
|
920d6f |
+ {
|
|
|
920d6f |
+ int i;
|
|
|
920d6f |
+ for (i=0; i
|
|
|
920d6f |
+ print (arg);
|
|
|
920d6f |
+ return NULL;
|
|
|
920d6f |
+ }
|
|
|
920d6f |
+
|
|
|
920d6f |
+ int
|
|
|
920d6f |
+ main (void)
|
|
|
920d6f |
+ {
|
|
|
920d6f |
+ pthread_t thread1;
|
|
|
920d6f |
+ pthread_t thread2;
|
|
|
920d6f |
+ pthread_t thread3;
|
|
|
920d6f |
+ pthread_create (&thread1, NULL, th_main, "aaa");
|
|
|
920d6f |
+ pthread_create (&thread2, NULL, th_main, "bbb");
|
|
|
920d6f |
+ pthread_create (&thread3, NULL, th_main, "ccc");
|
|
|
920d6f |
+ pthread_join (thread1, NULL);
|
|
|
920d6f |
+ pthread_join (thread2, NULL);
|
|
|
920d6f |
+ pthread_join (thread3, NULL);
|
|
|
920d6f |
+ return 0;
|
|
|
920d6f |
+ }
|
|
|
920d6f |
+}]]
|
|
|
920d6f |
|
|
|
920d6f |
-set testfile "main-threaded"
|
|
|
920d6f |
-set srcfile ${testfile}.c
|
|
|
920d6f |
-set binfile ${testfile}
|
|
|
920d6f |
-set libfile "main-lib"
|
|
|
920d6f |
-set libsrc $srcdir/$subdir/$libfile.c
|
|
|
920d6f |
-set lib_sl $objdir/$subdir/lib$testfile.so
|
|
|
920d6f |
-
|
|
|
920d6f |
-
|
|
|
920d6f |
-if [get_compiler_info $binfile] {
|
|
|
920d6f |
- return -1
|
|
|
920d6f |
-}
|
|
|
920d6f |
-
|
|
|
920d6f |
-verbose "compiling source file now....."
|
|
|
920d6f |
-if { [ltrace_compile_shlib $libsrc $lib_sl debug ] != ""
|
|
|
920d6f |
- || [ltrace_compile $srcdir/$subdir/$srcfile $objdir/$subdir/$binfile executable [list debug shlib=$lib_sl ldflags=-pthread] ] != ""} {
|
|
|
920d6f |
- send_user "Testcase compile failed, so all tests in this file will automatically fail.\n"
|
|
|
920d6f |
-}
|
|
|
920d6f |
-
|
|
|
920d6f |
-# set options for ltrace.
|
|
|
920d6f |
-ltrace_options "-l" "lib$testfile.so" "-f"
|
|
|
920d6f |
-
|
|
|
920d6f |
-# Run PUT for ltarce.
|
|
|
920d6f |
-set exec_output [ltrace_runtest $objdir/$subdir $objdir/$subdir/$binfile]
|
|
|
920d6f |
-
|
|
|
920d6f |
-# Check the output of this program.
|
|
|
920d6f |
-verbose "ltrace runtest output: $exec_output\n"
|
|
|
920d6f |
-if [regexp {ELF from incompatible architecture} $exec_output] {
|
|
|
920d6f |
- fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
|
|
|
920d6f |
- return
|
|
|
920d6f |
-} elseif [ regexp {Couldn't get .hash data} $exec_output ] {
|
|
|
920d6f |
- fail "Couldn't get .hash data!"
|
|
|
920d6f |
- return
|
|
|
920d6f |
-}
|
|
|
920d6f |
-
|
|
|
920d6f |
-# Verify the output by checking numbers of print in main-threaded.ltrace.
|
|
|
920d6f |
-set pattern "print"
|
|
|
920d6f |
-ltrace_verify_output ${objdir}/${subdir}/${testfile}.ltrace $pattern 30
|
|
|
920d6f |
+ltraceMatch1 [ltraceRun -f -l libprint.so -- $bin] {print\(} == 30
|
|
|
920d6f |
+
|
|
|
920d6f |
+ltraceDone
|
|
|
920d6f |
Only in ltrace.main: main-threaded.exp~
|
|
|
920d6f |
Only in ltrace.main: .main-threaded.exp.~undo-tree~
|