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