diff --git a/tools/regression/geom/Test/Makefile.inc b/tools/regression/geom/Test/Makefile.inc index 9e43900e02f2..c53257e06584 100644 --- a/tools/regression/geom/Test/Makefile.inc +++ b/tools/regression/geom/Test/Makefile.inc @@ -1,36 +1,36 @@ # $FreeBSD$ PROG = testprg NOMAN = no NOOBJ = youbet CFLAGS += -g -W -Wall -Wstrict-prototypes -Wmissing-prototypes CFLAGS += -Wpointer-arith -static -I/usr/src/sys -I../.. -CFLAGS += -DKERNELSIM +CFLAGS += -DKERNELSIM -pthread LDADD += -L../../GLib -lG LDADD += -L/usr/local/lib -lexpat DPADD += ../../GLib/libG.a CLEANFILES += _* *.core WARNS= 2 foo: echo ${SRCS} echo ${OBJS} ttest: ${PROG} ./${PROG} -t 2>&1 | tee _test tbtest: ${PROG} ./${PROG} -t -b 2>&1 | tee _test test: ${PROG} ./${PROG} .if exists(ref.conf) ../../ConfCmp/ConfCmp _1.conf ref.conf .endif echo "Passed ${.CURDIR}" mkref: mv _1.conf ref.conf gdb: gdb ${PROG} ${PROG}.core diff --git a/tools/regression/geom/Test/T000/testprg.c b/tools/regression/geom/Test/T000/testprg.c index fe2845538e10..eb53a9c70a82 100644 --- a/tools/regression/geom/Test/T000/testprg.c +++ b/tools/regression/geom/Test/T000/testprg.c @@ -1,66 +1,66 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); conff("1"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T001/testprg.c b/tools/regression/geom/Test/T001/testprg.c index 1c7865ac185a..263665ed39c2 100644 --- a/tools/regression/geom/Test/T001/testprg.c +++ b/tools/regression/geom/Test/T001/testprg.c @@ -1,69 +1,69 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.typo.ad0.xml"); rattle(); conff("1"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T002/testprg.c b/tools/regression/geom/Test/T002/testprg.c index 7ffcd68051b0..d7e6181834f4 100644 --- a/tools/regression/geom/Test/T002/testprg.c +++ b/tools/regression/geom/Test/T002/testprg.c @@ -1,69 +1,69 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.far.ad0.xml"); rattle(); conff("1"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T003/testprg.c b/tools/regression/geom/Test/T003/testprg.c index 70631efbc774..3acfcece390f 100644 --- a/tools/regression/geom/Test/T003/testprg.c +++ b/tools/regression/geom/Test/T003/testprg.c @@ -1,69 +1,69 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.msdos.ext.xml"); rattle(); conff("1"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T004/testprg.c b/tools/regression/geom/Test/T004/testprg.c index 705f6ed56b18..2c0dcd2fe78d 100644 --- a/tools/regression/geom/Test/T004/testprg.c +++ b/tools/regression/geom/Test/T004/testprg.c @@ -1,69 +1,69 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.critter.ad0.xml"); rattle(); conff("1"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T005/testprg.c b/tools/regression/geom/Test/T005/testprg.c index 119b3ede504c..af1d3f7732cb 100644 --- a/tools/regression/geom/Test/T005/testprg.c +++ b/tools/regression/geom/Test/T005/testprg.c @@ -1,69 +1,69 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.kern.flp.xml"); rattle(); conff("1"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T006/testprg.c b/tools/regression/geom/Test/T006/testprg.c index 10296af7ddaf..57c9522599c5 100644 --- a/tools/regression/geom/Test/T006/testprg.c +++ b/tools/regression/geom/Test/T006/testprg.c @@ -1,69 +1,69 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.msdos.flp.xml"); rattle(); conff("1"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T007/testprg.c b/tools/regression/geom/Test/T007/testprg.c index e07f87e4aab1..bc302be19ebf 100644 --- a/tools/regression/geom/Test/T007/testprg.c +++ b/tools/regression/geom/Test/T007/testprg.c @@ -1,73 +1,73 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.typo.ad0.xml"); rattle(); sdumpf("2a"); g_simdisk_destroy("ad0"); rattle(); conff("1"); sdumpf("2b"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T008/testprg.c b/tools/regression/geom/Test/T008/testprg.c index 21d960bb7e31..eca224afe9ac 100644 --- a/tools/regression/geom/Test/T008/testprg.c +++ b/tools/regression/geom/Test/T008/testprg.c @@ -1,75 +1,75 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { struct g_consumer *cp; rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.typo.ad0.xml"); rattle(); cp = g_dev_opendev("ad0s1a", 1, 0, 0); sdumpf("2a"); g_simdisk_destroy("ad0"); rattle(); conff("1"); sdumpf("2b"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T009/testprg.c b/tools/regression/geom/Test/T009/testprg.c index 3b2bfaf67965..ab71e9208477 100644 --- a/tools/regression/geom/Test/T009/testprg.c +++ b/tools/regression/geom/Test/T009/testprg.c @@ -1,89 +1,89 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { struct g_consumer *cp; struct bio *bp; rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.typo.ad0.xml"); rattle(); cp = g_dev_opendev("ad0s1a", 1, 0, 0); g_simdisk_stop("ad0"); bp = g_new_bio(); bp->bio_cmd = BIO_READ; bp->bio_offset = 0; bp->bio_length = 512; bp->bio_data = g_malloc(512, M_WAITOK); g_dev_request("ad0s1a", bp); rattle(); sdumpf("2a"); g_simdisk_destroy("ad0"); rattle(); conff("1"); sdumpf("2b"); g_simdisk_restart("ad0"); rattle(); conff("1"); sdumpf("2c"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T010/testprg.c b/tools/regression/geom/Test/T010/testprg.c index 12460545611f..29dd6ca77785 100644 --- a/tools/regression/geom/Test/T010/testprg.c +++ b/tools/regression/geom/Test/T010/testprg.c @@ -1,78 +1,78 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { struct g_consumer *cp; struct g_geom *gp; rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.empty.flp.xml"); rattle(); cp = g_dev_opendev("ad0", 1, 0, 0); g_topology_lock(); gp = g_create_geomf("BSD-class", cp->provider, NULL); g_topology_unlock(); printf("gp = %p\n", gp); rattle(); conff("1"); sdumpf("2"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T011/testprg.c b/tools/regression/geom/Test/T011/testprg.c index 455f6ef96ea9..44e4b694538c 100644 --- a/tools/regression/geom/Test/T011/testprg.c +++ b/tools/regression/geom/Test/T011/testprg.c @@ -1,78 +1,78 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { struct g_consumer *cp; struct g_geom *gp; rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.empty.flp.xml"); rattle(); cp = g_dev_opendev("ad0", 1, 0, 0); g_topology_lock(); gp = g_insert_geom("BSD-class", cp); g_topology_unlock(); printf("gp = %p\n", gp); rattle(); conff("1"); sdumpf("2"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T012/testprg.c b/tools/regression/geom/Test/T012/testprg.c index 0b9453d1de64..28645d70d01a 100644 --- a/tools/regression/geom/Test/T012/testprg.c +++ b/tools/regression/geom/Test/T012/testprg.c @@ -1,73 +1,73 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); g_sunlabel_init(); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.sun.da0.xml"); rattle(); g_simdisk_xml_load("ad0", "../../Data/disk.sun.da1.xml"); rattle(); conff("1"); sdumpf("2"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T013/testprg.c b/tools/regression/geom/Test/T013/testprg.c index aebd9d935149..f538a30aec3d 100644 --- a/tools/regression/geom/Test/T013/testprg.c +++ b/tools/regression/geom/Test/T013/testprg.c @@ -1,72 +1,72 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("da0", "../../Data/disk.beast.da0.xml"); g_simdisk_xml_load("da1", "../../Data/disk.alpha.da0.xml"); g_simdisk_xml_load("da2", "../../Data/disk.alpha2.da0.xml"); rattle(); conff("1"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/Test/T014/testprg.c b/tools/regression/geom/Test/T014/testprg.c index 5eba6d4c62a7..eb765816fee6 100644 --- a/tools/regression/geom/Test/T014/testprg.c +++ b/tools/regression/geom/Test/T014/testprg.c @@ -1,72 +1,72 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include -int +void * thread_sim(void *ptr __unused) { rattle(); g_simdisk_init(); g_bsd_init(); g_mbr_init(); g_mbrext_init(); g_sunlabel_init(); g_pc98_init(); g_dev_init(NULL); rattle(); g_simdisk_xml_load("wd0", "../../Data/disk.pc98.wdc0.xml"); rattle(); conff("1"); sdumpf("2"); printf("Done\n"); done(); return (0); } diff --git a/tools/regression/geom/geom.c b/tools/regression/geom/geom.c index 1852cc4d6266..1873e06b1c25 100644 --- a/tools/regression/geom/geom.c +++ b/tools/regression/geom/geom.c @@ -1,164 +1,192 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include void conff(char *file) { FILE *f; char *s; struct sbuf *sb; printf(">> conf to %s\n", file); asprintf(&s, "_%s.conf", file); f = fopen(s, "w"); if (f == NULL) err(1, s); sb = g_conf(); fputs(sbuf_data(sb), f); fclose(f); free(s); } - - - -static int +static void * thread_up(void *ptr) { struct thread *tp = ptr; + int error; printf("Running %s\n", tp->name); + error = pthread_cond_init(&ptc_up, NULL); + if (error) + err(1, "pthread_cond_init(ptc_up)"); + error = pthread_mutex_init(&ptm_up, NULL); + if (error) + err(1, "pthread_mutex_init(ptm_up)"); + + error = pthread_mutex_lock(&ptm_up); + if (error) + err(1, "pthread_mutex_init(ptm_up)"); for (;;) { g_io_schedule_up(tp); - tsleep(&g_wait_up, 0, "up", 0); + error = pthread_cond_wait(&ptc_up, &ptm_up); } } -static int +static void * thread_down(void *ptr) { struct thread *tp = ptr; + int error; + printf("Running %s\n", tp->name); + error = pthread_cond_init(&ptc_down, NULL); + if (error) + err(1, "pthread_cond_init(ptc_down)"); + error = pthread_mutex_init(&ptm_down, NULL); + if (error) + err(1, "pthread_mutex_init(ptm_down)"); + error = pthread_mutex_lock(&ptm_down); + if (error) + err(1, "pthread_mutex_init(ptm_down)"); for (;;) { g_io_schedule_down(tp); - tsleep(&g_wait_down, 0, "down", 0); + error = pthread_cond_wait(&ptc_down, &ptm_down); } } -static int +static void * thread_event(void *ptr) { struct thread *tp = ptr; - /* nice(5); */ + int error; + printf("Running %s\n", tp->name); + error = pthread_cond_init(&ptc_event, NULL); + if (error) + err(1, "pthread_cond_init(ptc_event)"); + error = pthread_mutex_init(&ptm_event, NULL); + if (error) + err(1, "pthread_mutex_init(ptm_event)"); + error = pthread_mutex_lock(&ptm_event); + if (error) + err(1, "pthread_mutex_init(ptm_event)"); for (;;) { - usleep(100000); g_run_events(); - tsleep(&g_wait_event, 0, "events", 0); + error = pthread_cond_wait(&ptc_event, &ptm_event); } } int main(int argc __unused, char **argv __unused) { int ch; while ((ch = getopt(argc, argv, "bt")) != -1) { switch (ch) { case 'b': g_debugflags |= G_T_BIO; break; case 't': g_debugflags |= G_T_TOPOLOGY; break; } } setbuf(stdout, NULL); printf("Sizeof g_class = %d\n", sizeof(struct g_class)); printf("Sizeof g_geom = %d\n", sizeof(struct g_geom)); printf("Sizeof g_consumer = %d\n", sizeof(struct g_consumer)); printf("Sizeof g_provider = %d\n", sizeof(struct g_provider)); printf("Sizeof g_event = %d\n", sizeof(struct g_event)); g_init(); new_thread(thread_up, "UP"); new_thread(thread_down, "DOWN"); new_thread(thread_event, "EVENT"); new_thread(thread_sim, "SIM"); while (1) { sleep (1); secrethandshake(); } } void sdumpf(char *file) { FILE *f; char *s; struct sbuf *sb; printf(">> dump to %s\n", file); asprintf(&s, "_%s.dot", file); f = fopen(s, "w"); if (f == NULL) err(1, s); sb = g_confdot(); fprintf(f, "%s", sbuf_data(sb)); fclose(f); free(s); asprintf(&s, "dot -Tps _%s.dot > _%s.ps", file, file); system(s); free(s); } diff --git a/tools/regression/geom/geom_kernsim.c b/tools/regression/geom/geom_kernsim.c index ba3ccf6534fa..7b925789fbf0 100644 --- a/tools/regression/geom/geom_kernsim.c +++ b/tools/regression/geom/geom_kernsim.c @@ -1,339 +1,288 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#include + #define NTHREAD 30 static struct thread thr[NTHREAD]; static int weredone; int g_debugflags; int bootverbose = 1; void done(void) { + + rattle(); weredone = 1; exit(0); } void secrethandshake() { int i; if (weredone) exit(0); for (i = 0; i < NTHREAD; i++) { if (thr[i].pid == 0) continue; if (kill(thr[i].pid, 0)) { printf("\n\nMissing process for thread %d (\"%s\")\n", i, thr[i].name); goto scram; } } return; scram: for (i = 0; i < NTHREAD; i++) { if (thr[i].pid == 0) continue; if (thr[i].pid == getpid()) continue; kill(thr[i].pid, 9); } exit(9); } -static int sleeping; void -wakeup(void *chan) +biodone(struct bio *bp) { - int i; + bp->bio_flags |= BIO_DONE; + if (bp->bio_done != NULL) + bp->bio_done(bp); +} - secrethandshake(); - for (i = 0; i < NTHREAD; i++) - if (thr[i].wchan == chan) { - printf("wakeup %s\n", thr[i].name); - atomic_clear_int(&sleeping, 1 << i); - write(thr[i].pipe[1], "\0", 1); - } +int +biowait(struct bio *bp, const char *wchan __unused) +{ + + while ((bp->bio_flags & BIO_DONE) == 0) + usleep(10000); + if (!(bp->bio_flags & BIO_ERROR)) + return (0); + if (bp->bio_error) + return (bp->bio_error); + return (EIO); +} + +void +wakeup(void *chan) +{ + + if (chan == &g_wait_event) + pthread_cond_signal(&ptc_event); + else if (chan == &g_wait_up) + pthread_cond_signal(&ptc_up); + else if (chan == &g_wait_down) + pthread_cond_signal(&ptc_down); + else + return; } int hz; int -tsleep(void *chan, int pri __unused, const char *wmesg, int timo) +tsleep(void *chan __unused, int pri __unused, const char *wmesg __unused, int timo) { - fd_set r,w,e; - int i, j, fd, pid; - struct timeval tv; - char buf[100]; - struct thread *tp; - secrethandshake(); - pid = getpid(); - tp = NULL; - for (i = 0; i < NTHREAD; i++) { - if (pid != thr[i].pid) - continue; - tp = &thr[i]; - break; - } - - KASSERT(tp != NULL, ("Confused tp=%p has no name\n", tp)); - KASSERT(tp->name != NULL, ("Confused tp=%p has no name\n", tp)); - tp->wchan = chan; - tp->wmesg = wmesg; - fd = tp->pipe[0]; - printf("tsleep %s %p %s\n", tp->name, chan, wmesg); - for (;;) { - if (timo > 0) { - tv.tv_sec = 1; - tv.tv_usec = 0; - } else { - tv.tv_sec = 3; - tv.tv_usec = 0; - } - FD_ZERO(&r); - FD_ZERO(&w); - FD_ZERO(&e); - FD_SET(fd, &r); - atomic_set_int(&sleeping, 1 << i); - j = select(fd + 1, &r, &w, &e, &tv); - secrethandshake(); - break; - } - if (j) - i = read(fd, buf, sizeof(buf)); - tp->wchan = 0; - tp->wmesg = 0; - return(i); + usleep(timo); + return (0); } void rattle() { - int i, j; + int i; + + pthread_yield(); for (;;) { - secrethandshake(); - usleep(500000); - secrethandshake(); - i = sleeping & 7; - if (i != 7) - continue; - usleep(20000); - j = sleeping & 7; - if (i != j) - continue; - printf("Rattle(%d) \"%s\" \"%s\" \"%s\"\n", i, thr[0].wmesg, thr[1].wmesg, thr[2].wmesg); - if (!thr[0].wmesg || strcmp(thr[0].wmesg, "up")) - continue; - if (!thr[1].wmesg || strcmp(thr[1].wmesg, "down")) - continue; - if (!thr[2].wmesg || strcmp(thr[2].wmesg, "events")) - continue; - break; + i = pthread_mutex_trylock(&ptm_up); + if (i != EBUSY) { + i = pthread_mutex_trylock(&ptm_down); + if (i != EBUSY) { + i = pthread_mutex_trylock(&ptm_event); + if (i != EBUSY) + break; + pthread_mutex_unlock(&ptm_down); + } + pthread_mutex_unlock(&ptm_up); + } + usleep(100000); } + pthread_mutex_unlock(&ptm_event); + pthread_mutex_unlock(&ptm_down); + pthread_mutex_unlock(&ptm_up); + return; } void -new_thread(int (*func)(void *arg), char *name) +new_thread(void *(*func)(void *arg), char *name) { - char *c; struct thread *tp; static int nextt; + int error; tp = thr + nextt++; - c = calloc(1, 65536); + error = pthread_create(&tp->tid, NULL, func, tp); + if (error) + err(1, "pthread_create(%s)", name); tp->name = name; - pipe(tp->pipe); - tp->pid = rfork_thread(RFPROC|RFMEM, c + 65536 - 16, func, tp); - if (tp->pid <= 0) - err(1, "rfork_thread"); printf("New Thread %d %s %p %d\n", tp - thr, name, tp, tp->pid); } #define FASCIST 0 -int malloc_lock; void * g_malloc(int size, int flags) { void *p; - secrethandshake(); - while (!atomic_cmpset_int(&malloc_lock, 0, 1)) - sched_yield(); #if FASCIST p = malloc(4096); printf("Malloc %p \n", p); #else p = malloc(size); #endif - malloc_lock = 0; if (flags & M_ZERO) memset(p, 0, size); else memset(p, 0xd0, size); return (p); } void g_free(void *ptr) { secrethandshake(); - while (!atomic_cmpset_int(&malloc_lock, 0, 1)) - sched_yield(); #if FASCIST printf("Free %p \n", ptr); munmap(ptr, 4096); #else free(ptr); #endif - malloc_lock = 0; } +static pthread_mutex_t pt_topology; void g_init(void) { + pthread_mutex_init(&pt_topology, NULL); g_io_init(); g_event_init(); } -static int topology_lock; - void g_topology_lock() { - int pid; - pid = getpid(); - if (atomic_cmpset_int(&topology_lock, 0, pid)) - return; - KASSERT(pid != topology_lock, - ("Locking topology against myself pid %d\n", pid)); - while (!atomic_cmpset_int(&topology_lock, 0, pid)) { - printf("Waiting for topology lock mypid = %d held by %d\n", - pid, topology_lock); - sleep(1); - } + pthread_mutex_lock(&pt_topology); } void g_topology_unlock() { - KASSERT(topology_lock == getpid(), ("Didn't have topology_lock to release")); - topology_lock = 0; + pthread_mutex_unlock(&pt_topology); } void g_topology_assert() { +#if 0 if (topology_lock == getpid()) return; KASSERT(1 == 0, ("Lacking topology_lock")); -} - -void -mtx_lock_spin(struct mtx *mp) -{ - - while(!atomic_cmpset_int(&mp->mtx_lock, 0, 1)) { - printf("trying to get lock...\n"); - sched_yield(); - } -} - -void -mtx_unlock_spin(struct mtx *mp) -{ - - mp->mtx_lock = 0; +#endif } void mtx_init(struct mtx *mp, const char *bla __unused, const char *yak __unused, int foo __unused) { - mp->mtx_lock = 0; + + pthread_mutex_init((pthread_mutex_t *)&mp->mtx_object, NULL); } void mtx_destroy(struct mtx *mp) { - mp->mtx_lock = 0; + + pthread_mutex_destroy((pthread_mutex_t *)&mp->mtx_object); } void mtx_lock(struct mtx *mp) { - mp->mtx_lock = 0; + pthread_mutex_lock((pthread_mutex_t *)&mp->mtx_object); } void mtx_unlock(struct mtx *mp) { - mp->mtx_lock = 0; + pthread_mutex_unlock((pthread_mutex_t *)&mp->mtx_object); } struct mtx Giant; diff --git a/tools/regression/geom/geom_sim.h b/tools/regression/geom/geom_sim.h index df082209f995..6ea0470d1771 100644 --- a/tools/regression/geom/geom_sim.h +++ b/tools/regression/geom/geom_sim.h @@ -1,152 +1,159 @@ /*- * Copyright (c) 2002 Poul-Henning Kamp * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Poul-Henning Kamp * and NAI Labs, the Security Research Division of Network Associates, Inc. * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the * DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ +#include + +pthread_cond_t ptc_up, ptc_down, ptc_event; +pthread_mutex_t ptm_up, ptm_down, ptm_event; /* bio.h */ struct bio { enum { BIO_INVALID = 0, - BIO_READ, - BIO_WRITE, - BIO_FREE, - BIO_DELETE, - BIO_FORMAT, - BIO_GETATTR, - BIO_SETATTR + BIO_READ = 1, + BIO_WRITE = 2, + BIO_DELETE = 4, + BIO_GETATTR = 8, + BIO_SETATTR = 16 } bio_cmd; struct { int foo; } stats; TAILQ_ENTRY(bio) bio_queue; TAILQ_ENTRY(bio) bio_sort; struct g_consumer *bio_from; struct g_provider *bio_to; void (*bio_done)(struct bio *); off_t bio_offset; off_t bio_length; off_t bio_completed; void *bio_data; const char *bio_attribute; /* BIO_GETATTR/BIO_SETATTR */ int bio_error; struct bio *bio_linkage; int bio_flags; #define BIO_DONE 0x1 +#define BIO_ERROR 0x2 }; +void biodone(struct bio *bp); +int biowait(struct bio *bp, const char *wchan); + /* geom_dev.c */ void g_dev_init(void *junk); struct g_consumer *g_dev_opendev(char *name, int w, int r, int e); int g_dev_request(char *name, struct bio *bp); /* geom_kernsim.c */ struct thread { char *name; + pthread_t tid; int pid; void *wchan; const char *wmesg; int pipe[2]; }; void done(void); void rattle(void); void secrethandshake(void); void wakeup(void *chan); int tsleep __P((void *chan, int pri, const char *wmesg, int timo)); #define PPAUSE 0 extern int hz; -void new_thread(int (*func)(void *arg), char *name); +void new_thread(void *(*func)(void *arg), char *name); extern int bootverbose; #define KASSERT(cond, txt) do {if (!(cond)) {printf txt; conff("err"); abort();}} while(0) #define M_WAITOK 0 #define M_ZERO 1 extern struct mtx Giant; void *g_malloc(int size, int flags); void g_free(void *ptr); #define MTX_DEF 0 #define MTX_SPIN 1 void mtx_lock(struct mtx *); void mtx_lock_spin(struct mtx *); void mtx_unlock(struct mtx *); void mtx_unlock_spin(struct mtx *); void mtx_init(struct mtx *, const char *, const char *, int); void mtx_destroy(struct mtx *); #define MALLOC_DECLARE(foo) /* */ void g_topology_lock(void); void g_topology_unlock(void); void g_topology_assert(void); /* geom_simdisk.c */ void g_simdisk_init(void); void g_simdisk_destroy(char *); struct g_geom *g_simdisk_new(char *, char *); struct g_geom * g_simdisk_xml_load(char *name, char *file); void g_simdisk_xml_save(char *name, char *file); void g_simdisk_stop(char *name); void g_simdisk_restart(char *name); #define DECLARE_GEOM_CLASS(class, name) \ void \ name##_init(void) \ { \ g_add_class(&class); \ } void g_pc98_init(void); void g_sunlabel_init(void); void g_bsd_init(void); void g_mbr_init(void); void g_mbrext_init(void); -int thread_sim(void *ptr); +void *thread_sim(void *ptr); void dumpf(char *file); void conff(char *file); void sdumpf(char *file); #define THR_MAIN 0 #define THR_UP 1 #define THR_DOWN 2 #define THR_EVENT 3