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