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.6 PTH_1_0b7:1.6 PTH_1_0b6:1.6 PTH_1_0b5:1.6 PTH_1_0b4:1.6 PTH_1_0b3:1.4 PTH_1_0b2:1.4 PTH_1_0b1:1.2; locks; strict; comment @ * @; 1.22 date 2007.01.01.18.23.53; author rse; state Exp; branches; next 1.21; commitid 9DhdiirNzQPBIP0s; 1.21 date 2006.06.08.17.54.54; author rse; state Exp; branches; next 1.20; commitid x8N3mLVdQgkbdeAr; 1.20 date 2004.12.31.19.34.45; author rse; state Exp; branches; next 1.19; 1.19 date 2004.07.13.10.50.49; author rse; state Exp; branches; next 1.18; 1.18 date 2003.01.01.15.49.12; author rse; state Exp; branches; next 1.17; 1.17 date 2002.11.03.09.24.42; author rse; state Exp; branches; next 1.16; 1.16 date 2002.01.27.11.03.41; author rse; state Exp; branches; next 1.15; 1.15 date 2001.03.24.14.51.05; author rse; state Exp; branches; next 1.14; 1.14 date 99.12.30.21.59.02; author rse; state Exp; branches; next 1.13; 1.13 date 99.11.09.08.11.33; author rse; state Exp; branches; next 1.12; 1.12 date 99.11.01.10.27.22; author rse; state Exp; branches; next 1.11; 1.11 date 99.10.31.11.46.14; author rse; state Exp; branches 1.11.2.1; next 1.10; 1.10 date 99.09.17.08.01.56; author rse; state Exp; branches; next 1.9; 1.9 date 99.08.18.14.54.26; author rse; state Exp; branches; next 1.8; 1.8 date 99.08.18.14.52.07; author rse; state Exp; branches; next 1.7; 1.7 date 99.08.15.15.20.35; author rse; state Exp; branches; next 1.6; 1.6 date 99.07.08.10.34.02; author rse; state Exp; branches; next 1.5; 1.5 date 99.07.08.10.19.12; author rse; state Exp; branches; next 1.4; 1.4 date 99.07.04.14.05.10; author rse; state Exp; branches; next 1.3; 1.3 date 99.07.04.12.05.36; author rse; state Exp; branches; next 1.2; 1.2 date 99.06.28.11.37.31; author rse; state Exp; branches; next 1.1; 1.1 date 99.06.28.11.36.26; author rse; state Exp; branches; next ; 1.11.2.1 date 99.11.01.10.25.03; author rse; state Exp; branches; next ; desc @@ 1.22 log @Adjusted all copyright messages for new year 2007. @ text @/* ** GNU Pth - The GNU Portable Threads ** Copyright (c) 1999-2007 Ralf S. Engelschall ** ** This file is part of GNU Pth, a non-preemptive thread scheduling ** library which can be found at http://www.gnu.org/software/pth/. ** ** This library is free software; you can redistribute it and/or ** modify it under the terms of the GNU Lesser General Public ** License as published by the Free Software Foundation; either ** version 2.1 of the License, or (at your option) any later version. ** ** This library 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 ** Lesser General Public License for more details. ** ** You should have received a copy of the GNU Lesser General Public ** License along with this library; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 ** USA, or contact Ralf S. Engelschall . ** ** test_std.c: Pth standard test program */ /* ``Understanding a problem is knowing why it is hard to solve it, and why the most straightforward approaches won't work.'' -- Karl Popper */ #include #include #include #include #include #include #include "pth.h" #define FAILED_IF(expr) \ if (expr) { \ fprintf(stderr, "*** ERROR, TEST FAILED:\n*** errno=%d\n\n", errno); \ exit(1); \ } static void *t1_func(void *arg) { int i; long val; val = (long)arg; FAILED_IF(val != 123) for (i = 0; i < 100; i++) { val += 10; pth_yield(NULL); } return (void *)val; } static void *t2_func(void *arg) { long val; pth_t tid; void *rval; int rc; val = (long)arg; if (val < 9) { val++; fprintf(stderr, "Spawning thread %ld\n", val); tid = pth_spawn(PTH_ATTR_DEFAULT, t2_func, (void *)(val)); FAILED_IF(tid == NULL) rc = pth_join(tid, &rval); fprintf(stderr, "Joined thread %ld\n", val); FAILED_IF(rc == FALSE) rval = (void *)((long)arg * (long)rval); } else rval = arg; return rval; } int main(int argc, char *argv[]) { fprintf(stderr, "\n=== TESTING GLOBAL LIBRARY API ===\n\n"); { int version; fprintf(stderr, "Fetching library version\n"); version = pth_version(); FAILED_IF(version == 0x0) fprintf(stderr, "version = 0x%X\n", version); } fprintf(stderr, "\n=== TESTING BASIC OPERATION ===\n\n"); { int rc; fprintf(stderr, "Initializing Pth system (spawns scheduler and main thread)\n"); rc = pth_init(); FAILED_IF(rc == FALSE) fprintf(stderr, "Killing Pth system for testing purposes\n"); pth_kill(); fprintf(stderr, "Re-Initializing Pth system\n"); rc = pth_init(); FAILED_IF(rc == FALSE) } fprintf(stderr, "\n=== TESTING BASIC THREAD OPERATION ===\n\n"); { pth_attr_t attr; pth_t tid; void *val; int rc; fprintf(stderr, "Creating attribute object\n"); attr = pth_attr_new(); FAILED_IF(attr == NULL) rc = pth_attr_set(attr, PTH_ATTR_NAME, "test1"); FAILED_IF(rc == FALSE) rc = pth_attr_set(attr, PTH_ATTR_PRIO, PTH_PRIO_MAX); FAILED_IF(rc == FALSE) fprintf(stderr, "Spawning thread\n"); tid = pth_spawn(attr, t1_func, (void *)(123)); FAILED_IF(tid == NULL) pth_attr_destroy(attr); fprintf(stderr, "Joining thread\n"); rc = pth_join(tid, &val); FAILED_IF(rc == FALSE) FAILED_IF(val != (void *)(1123)) } fprintf(stderr, "\n=== TESTING NESTED THREAD OPERATION ===\n\n"); { pth_t tid; void *val; int rc; fprintf(stderr, "Spawning thread 1\n"); tid = pth_spawn(PTH_ATTR_DEFAULT, t2_func, (void *)(1)); FAILED_IF(tid == NULL) rc = pth_join(tid, &val); fprintf(stderr, "Joined thread 1\n"); FAILED_IF(rc == FALSE) FAILED_IF(val != (void *)(1*2*3*4*5*6*7*8*9)) } pth_kill(); fprintf(stderr, "\nOK - ALL TESTS SUCCESSFULLY PASSED.\n\n"); exit(0); } @ 1.21 log @Adjusted all copyright messages for new year 2006 @ text @d3 1 a3 1 ** Copyright (c) 1999-2006 Ralf S. Engelschall @ 1.20 log @Adjusted all copyright messages for new year 2005. @ text @d3 1 a3 1 ** Copyright (c) 1999-2005 Ralf S. Engelschall @ 1.19 log @Adjusted all copyright messages for new year 2004. @ text @d3 1 a3 1 ** Copyright (c) 1999-2004 Ralf S. Engelschall @ 1.18 log @Adjusted all copyright messages for new year 2003. @ text @d3 1 a3 1 ** Copyright (c) 1999-2003 Ralf S. Engelschall @ 1.17 log @add a bunch of cookies @ text @d3 1 a3 1 ** Copyright (c) 1999-2002 Ralf S. Engelschall @ 1.16 log @bump copyright year @ text @d25 4 a28 1 @ 1.15 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999-2001 Ralf S. Engelschall @ 1.14 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999-2000 Ralf S. Engelschall @ 1.13 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999 Ralf S. Engelschall @ 1.12 log @*** empty log message *** @ text @d78 1 a78 1 int main(int argc, char *argv[]) d89 1 a89 1 d103 1 a103 1 d118 1 a118 1 d129 1 a129 1 @ 1.11 log @*** empty log message *** @ text @d2 1 a2 2 ** test_std.c -- Pth standard test program ** d22 2 @ 1.11.2.1 log @*** empty log message *** @ text @d2 2 a3 1 ** GNU Pth - The GNU Portable Threads a22 2 ** ** test_std.c: Pth standard test program @ 1.10 log @*** empty log message *** @ text @d12 1 a12 1 ** version 2 of the License, or (at your option) any later version. @ 1.9 log @*** empty log message *** @ text @d10 1 a10 1 ** modify it under the terms of the GNU Library General Public d17 1 a17 1 ** Library General Public License for more details. d19 1 a19 1 ** You should have received a copy of the GNU Library General Public @ 1.8 log @*** empty log message *** @ text @d72 1 a72 1 else { a73 1 } @ 1.7 log @*** empty log message *** @ text @d54 24 d104 1 a104 1 fprintf(stderr, "\n=== TESTING THREAD OPERATION ===\n\n"); d128 16 @ 1.6 log @*** empty log message *** @ text @d36 1 a36 4 char *e; \ e = strerror(errno); \ fprintf(stderr, "*** ERROR, TEST FAILED:\n*** %s\n\n", \ e != NULL ? e : "Unknown Error"); \ @ 1.5 log @*** empty log message *** @ text @d2 1 a2 1 ** test_std.c -- PTH standard test program d73 1 a73 1 fprintf(stderr, "Initializing PTH system (spawns scheduler and main thread)\n"); d76 1 a76 1 fprintf(stderr, "Killing PTH system for testing purposes\n"); d78 1 a78 1 fprintf(stderr, "Re-Initializing PTH system\n"); @ 1.4 log @*** empty log message *** @ text @d6 2 a7 2 ** This file is part of PTH, a non-preemptive thread scheduling library ** which can be found at http://www.gnu.org/software/pth/. @ 1.3 log @*** empty log message *** @ text @d46 1 a46 1 int val; d48 1 a48 1 val = (int)arg; d106 1 a106 1 FAILED_IF((int)val != 1123) @ 1.2 log @*** empty log message *** @ text @d7 1 a7 1 ** which can be found at http://www.engelschall.com/sw/pth/. @ 1.1 log @*** empty log message *** @ text @d38 2 a39 1 fprintf(stderr, "*** ERROR, TEST FAILED:\n*** %s\n", e != NULL ? e : "Unknown Error"); \ d110 1 a110 1 fprintf(stderr, "\nOK - ALL TESTS SUCCESSFULLY PASSED.\n"); @