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