tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Google summer code 2016 project ideas
In article <CA+SXE9vg=p9vF=SoZuYU_1rzUu9LyJhMeff2qmWRm9e05d-LSA%mail.gmail.com@localhost>,
Charles Cui <charles.cui1984%gmail.com@localhost> wrote:
>-=-=-=-=-=-
>
>One question about porting posix test suite onto netbsd.
>Right now the suite can execute on Linux and mac OS(I have not tested
>others),
>there should be some fixes in Makefile to let it run on netbsd because it
>cannot be compiled now.
>My question is the output of this suite on Linux (and macOS) reports PASS
>for some tests and FAILED for some others.
>My question about the porting is after changing the makefile to make it run
>on netbsd, shall we change the kernel to make all failed tests pass?
>Or making all tests execute is the goal and we do not care about the result?
For now just build and install gnu make from pkgsrc and use that to build.
Once we make progress we can think about making the build more portable.
Here are some patches that I've added...
christos
diff --git a/LDFLAGS b/LDFLAGS
index aa701d9..81b7599 100644
--- a/LDFLAGS
+++ b/LDFLAGS
@@ -14,3 +14,4 @@
# allow for the NPTL-specific compilation (used in some test cases)
# Note: this sometimes require the package nptl-devel.*.rpm to be installed.
#-I /usr/include/nptl -L /usr/lib/nptl -D_XOPEN_SOURCE=600 -lpthread -lrt -lm
+-lpthread -lrt -lm
diff --git a/conformance/interfaces/aio_write/7-1.c b/conformance/interfaces/aio_write/7-1.c
index 8f13f30..3b7f819 100644
--- a/conformance/interfaces/aio_write/7-1.c
+++ b/conformance/interfaces/aio_write/7-1.c
@@ -84,6 +84,8 @@ int main()
for (i=0; i<last_req-1; i++)
{
err = aio_error(&aiocbs[i]);
+ if (err != 0)
+ printf(TNAME " aio_error got %d\n", err);
ret = aio_return(&aiocbs[i]);
}
diff --git a/conformance/interfaces/lio_listio/1-1.c b/conformance/interfaces/lio_listio/1-1.c
index c86e318..23ba2b8 100644
--- a/conformance/interfaces/lio_listio/1-1.c
+++ b/conformance/interfaces/lio_listio/1-1.c
@@ -23,6 +23,7 @@
#define _XOPEN_SOURCE 600
#include <stdio.h>
+#include <signal.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
diff --git a/conformance/interfaces/mmap/11-2.c b/conformance/interfaces/mmap/11-2.c
index 4ea16be..a284392 100644
--- a/conformance/interfaces/mmap/11-2.c
+++ b/conformance/interfaces/mmap/11-2.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <signal.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/conformance/interfaces/mmap/11-3.c b/conformance/interfaces/mmap/11-3.c
index 7b3d26f..c88d39b 100644
--- a/conformance/interfaces/mmap/11-3.c
+++ b/conformance/interfaces/mmap/11-3.c
@@ -20,6 +20,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
diff --git a/conformance/interfaces/mmap/27-1.c b/conformance/interfaces/mmap/27-1.c
index 1a8e1d3..344db9c 100644
--- a/conformance/interfaces/mmap/27-1.c
+++ b/conformance/interfaces/mmap/27-1.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <signal.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -62,6 +63,12 @@ int main()
#endif
data = (char *) malloc(total_size);
+ if (data == NULL)
+ {
+ printf(TNAME "Error in malloc(): %s\n",
+ strerror(errno));
+ exit(PTS_UNRESOLVED);
+ }
snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_mmap_27_1_%d",
getpid());
unlink(tmpfname);
diff --git a/conformance/interfaces/mmap/6-1.c b/conformance/interfaces/mmap/6-1.c
index 7857f5c..e03dfbe 100644
--- a/conformance/interfaces/mmap/6-1.c
+++ b/conformance/interfaces/mmap/6-1.c
@@ -26,6 +26,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
diff --git a/conformance/interfaces/mmap/6-2.c b/conformance/interfaces/mmap/6-2.c
index a37f679..5d9d51b 100644
--- a/conformance/interfaces/mmap/6-2.c
+++ b/conformance/interfaces/mmap/6-2.c
@@ -29,6 +29,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
diff --git a/conformance/interfaces/mmap/6-3.c b/conformance/interfaces/mmap/6-3.c
index c0ab5db..bc66ad1 100644
--- a/conformance/interfaces/mmap/6-3.c
+++ b/conformance/interfaces/mmap/6-3.c
@@ -27,6 +27,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
diff --git a/conformance/interfaces/munmap/1-1.c b/conformance/interfaces/munmap/1-1.c
index 35f0eb4..328119a 100644
--- a/conformance/interfaces/munmap/1-1.c
+++ b/conformance/interfaces/munmap/1-1.c
@@ -28,6 +28,7 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
+#include <signal.h>
#include <string.h>
#include <errno.h>
#include "posixtest.h"
diff --git a/conformance/interfaces/munmap/1-2.c b/conformance/interfaces/munmap/1-2.c
index 3d4cc3a..77560b9 100644
--- a/conformance/interfaces/munmap/1-2.c
+++ b/conformance/interfaces/munmap/1-2.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <signal.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/conformance/interfaces/sched_yield/1-1.c b/conformance/interfaces/sched_yield/1-1.c
index 7437e0a..670abef 100644
--- a/conformance/interfaces/sched_yield/1-1.c
+++ b/conformance/interfaces/sched_yield/1-1.c
@@ -19,11 +19,16 @@
* 4. Launch a thread which call sched_yield() and check that the counter has
* changed since the call.
*/
-#define LINUX
-
-#ifdef LINUX
+#ifdef __linux__
#define _GNU_SOURCE
#endif
+#ifdef __NetBSD__
+#define _NETBSD_SOURCE
+#endif
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/wait.h>
#include <sched.h>
#include <stdio.h>
@@ -31,18 +36,16 @@
#include <stdlib.h>
#include <signal.h>
#include <pthread.h>
+#include <inttypes.h>
+#include <stdint.h>
#include <errno.h>
-#include <sys/wait.h>
#include "posixtest.h"
#ifdef BSD
-# include <sys/types.h>
-# include <sys/param.h>
# include <sys/sysctl.h>
#endif
#ifdef HPUX
-# include <sys/param.h>
# include <sys/pstat.h>
#endif
@@ -78,10 +81,10 @@ int get_ncpu() {
return ncpu;
}
-#ifdef LINUX
int set_process_affinity(int cpu)
{
int retval = -1;
+#if defined(CPU_ZERO)
cpu_set_t cpu_mask;
CPU_ZERO(&cpu_mask);
@@ -91,12 +94,23 @@ int set_process_affinity(int cpu)
fprintf (stderr, "Wrong cpu id: %d\n", cpu);
return -1;
}
-
-//#ifndef P2_SCHED_SETAFFINITY
retval = sched_setaffinity(0, sizeof(cpu_mask), &cpu_mask);
-//#else
-// retval = sched_setaffinity(0, &cpu_mask);
-//#endif
+#elif defined(cpuset_create)
+ cpuset_t *cpu_mask = cpuset_create();
+
+ cpuset_zero(cpu_mask);
+ if (cpu >= 0 && cpu <= cpuset_size(cpu_mask)) {
+ cpuset_set(cpu, cpu_mask);
+ } else {
+ fprintf (stderr, "Wrong cpu id: %d\n", cpu);
+ return -1;
+ }
+ retval = _sched_setaffinity(0, 0, cpuset_size(cpu_mask), cpu_mask);
+ cpuset_destroy(cpu_mask);
+#else
+ #error "no cpuset"
+#endif
+
if (retval == -1)
perror("Error at sched_setaffinity()");
@@ -106,6 +120,7 @@ int set_process_affinity(int cpu)
int set_thread_affinity(int cpu)
{
int retval = -1;
+#if defined(CPU_ZERO)
cpu_set_t cpu_mask;
CPU_ZERO(&cpu_mask);
@@ -115,26 +130,34 @@ int set_thread_affinity(int cpu)
fprintf (stderr, "Wrong cpu id: %d\n", cpu);
return -1;
}
-//#ifndef P2_PTHREAD_SETAFFINITY
retval = pthread_setaffinity_np(pthread_self(),
sizeof(cpu_mask), &cpu_mask);
-//#else
-// retval = pthread_setaffinity_np(pthread_self(), &cpu_mask);
-//#endif
+#elif defined(cpuset_create)
+ cpuset_t *cpu_mask = cpuset_create();
+
+ cpuset_zero(cpu_mask);
+ if (cpu >= 0 && cpu <= cpuset_size(cpu_mask)) {
+ cpuset_set(cpu, cpu_mask);
+ } else {
+ fprintf (stderr, "Wrong cpu id: %d\n", cpu);
+ return -1;
+ }
+ retval = pthread_setaffinity_np(0, cpuset_size(cpu_mask), cpu_mask);
+ cpuset_destroy(cpu_mask);
+#else
+ #error "no cpuset"
+#endif
if (retval != 0)
fprintf (stderr, "Error at pthread_setaffinity_np():\n");
return retval;
}
-#endif
void * runner(void * arg) {
int i=0, nc;
long result = 0;
-#ifdef LINUX
set_thread_affinity(*(int *)arg);
- fprintf(stderr, "%ld bind to cpu: %d\n", pthread_self(), *(int*)arg);
-#endif
+ fprintf(stderr, "%jd bind to cpu: %d\n", (intmax_t)pthread_self(), *(int*)arg);
for(;i<LOOP;i++){
nc = nb_call;
@@ -154,10 +177,8 @@ void * runner(void * arg) {
}
void * busy_thread(void *arg){
-#ifdef LINUX
set_thread_affinity(*(int *)arg);
- fprintf(stderr, "%ld bind to cpu: %d\n", pthread_self(), *(int*)arg);
-#endif
+ fprintf(stderr, "%jd bind to cpu: %d\n", (intmax_t)pthread_self(), *(int*)arg);
while(1){
nb_call++;
sched_yield();
@@ -170,11 +191,9 @@ void * busy_thread(void *arg){
void buzy_process(int cpu){
struct sched_param param;
-#ifdef LINUX
/* Bind to a processor */
set_process_affinity(cpu);
fprintf(stderr, "%d bind to cpu: %d\n", getpid(), cpu);
-#endif
param.sched_priority = sched_get_priority_max(SCHED_FIFO);
if(sched_setscheduler(getpid(), SCHED_FIFO, ¶m) != 0) {
perror("An error occurs when calling sched_setparam()");
diff --git a/run_tests b/run_tests
index 1e06b9e..e5b6318 100755
--- a/run_tests
+++ b/run_tests
@@ -23,8 +23,8 @@ EOF
runtests()
{
for test in `ls -d $1`; do
- POSIX_TARGET=$test make build-tests
- POSIX_TARGET=$test make run-tests
+ POSIX_TARGET=$test gmake build-tests
+ POSIX_TARGET=$test gmake run-tests
done
}
diff --git a/stress/mqueues/Makefile b/stress/mqueues/Makefile
index 49e8e4a..2ca58dd 100644
--- a/stress/mqueues/Makefile
+++ b/stress/mqueues/Makefile
@@ -4,7 +4,8 @@ ifndef POSIX_DIR_LIB
endif
INCLUDE = -I../../include
-LIB=-lmqueue
+#LIB=-lmqueue
+LIB=-lrt
CC=gcc
CFLAGS=-Wall -O2 -g -I$(POSIX_DIR_INC) -L$(POSIX_DIR_LIB) -lpthread
diff --git a/stress/mqueues/run.sh b/stress/mqueues/run.sh
index 37f34d8..47c2cf6 100755
--- a/stress/mqueues/run.sh
+++ b/stress/mqueues/run.sh
@@ -11,22 +11,24 @@
RunTest()
{
echo "TEST: " $1 $2
- TOTAL=$TOTAL+1
+ TOTAL=$((TOTAL+1))
./$1 $2
- if [ $? == 0 ]; then
- PASS=$PASS+1
- echo -ne "\t\t\t***TEST PASSED***\n\n"
+ if [ $? = 0 ]; then
+ PASS=$((PASS+1))
+ echo " ***TEST PASSED***"
+ echo
else
- FAIL=$FAIL+1
- echo -ne "\t\t\t***TEST FAILED***\n\n"
+ FAIL=$((FAIL+1))
+ echo " ***TEST FAILED***"
+ echo
fi
}
# Main program
-declare -i TOTAL=0
-declare -i PASS=0
-declare -i FAIL=0
+TOTAL=0
+PASS=0
+FAIL=0
# Add lists of tests to these variables for execution
TESTS="multi_send_rev_1.test multi_send_rev_2.test"
@@ -39,11 +41,11 @@ RunTest multi_send_rev_2.test 100
echo
-echo -ne "\t\t****************\n"
-echo -ne "\t\t* TOTAL: " $TOTAL "\n"
-echo -ne "\t\t* PASSED: " $PASS "\n"
-echo -ne "\t\t* FAILED: " $FAIL "\n"
-echo -ne "\t\t****************\n"
+echo " ****************"
+echo " * TOTAL: " $TOTAL
+echo " * PASSED: " $PASS
+echo " * FAILED: " $FAIL
+echo " ****************"
exit 0
diff --git a/stress/semaphores/Makefile b/stress/semaphores/Makefile
index 387b7ff..113a382 100644
--- a/stress/semaphores/Makefile
+++ b/stress/semaphores/Makefile
@@ -3,7 +3,7 @@ ifndef POSIX_DIR_LIB
endif
INCLUDE = -I../../include
-LIB=-lposix1b
+#LIB=-lposix1b
CC=gcc
CFLAGS=-Wall -O2 -g -I$(POSIX_DIR_INC) -L$(POSIX_DIR_LIB)
diff --git a/stress/semaphores/run.sh b/stress/semaphores/run.sh
index 8812b56..42fa5ae 100755
--- a/stress/semaphores/run.sh
+++ b/stress/semaphores/run.sh
@@ -11,22 +11,24 @@
RunTest()
{
echo "TEST: " $1 $2
- TOTAL=$TOTAL+1
+ TOTAL=$((TOTAL+1))
./$1 $2
- if [ $? == 0 ]; then
- PASS=$PASS+1
- echo -ne "\t\t\t***TEST PASSED***\n\n"
+ if [ $? = 0 ]; then
+ PASS=$((PASS+1))
+ echo " ***TEST PASSED***"
+ echo
else
- FAIL=$FAIL+1
- echo -ne "\t\t\t***TEST FAILED***\n\n"
+ FAIL=$((FAIL+1))
+ echo " ***TEST FAILED***"
+ echo
fi
}
# Main program
-declare -i TOTAL=0
-declare -i PASS=0
-declare -i FAIL=0
+TOTAL=0
+PASS=0
+FAIL=0
# Add lists of tests to these variables for execution
TESTS="multi_con_pro.test"
@@ -37,11 +39,11 @@ echo "=========================================="
RunTest $TESTS 100
echo
-echo -ne "\t\t****************\n"
-echo -ne "\t\t* TOTAL: " $TOTAL "\n"
-echo -ne "\t\t* PASSED: " $PASS "\n"
-echo -ne "\t\t* FAILED: " $FAIL "\n"
-echo -ne "\t\t****************\n"
+echo " ****************"
+echo " * TOTAL: " $TOTAL
+echo " * PASSED: " $PASS
+echo " * FAILED: " $FAIL
+echo " ****************"
exit 0
diff --git a/stress/threads/fork/do-plot b/stress/threads/fork/do-plot
index 3789b46..08797f6 100755
--- a/stress/threads/fork/do-plot
+++ b/stress/threads/fork/do-plot
@@ -15,12 +15,12 @@
FILE=$1
TMP=$(mktemp -d)
-function clean_up
+clean_up()
{
rm -rf $TMP
}
-function error
+error()
{
cat 1>&2
clean_up
diff --git a/stress/threads/fork/s-c1.c b/stress/threads/fork/s-c1.c
index ba257fd..668d899 100644
--- a/stress/threads/fork/s-c1.c
+++ b/stress/threads/fork/s-c1.c
@@ -130,7 +130,7 @@ int main ( int argc, char *argv[] )
mes_t sentinel;
mes_t *m_cur, *m_tmp;
- long CHILD_MAX = sysconf( _SC_CHILD_MAX );
+ long MY_CHILD_MAX = sysconf( _SC_CHILD_MAX );
long my_max = 1000 * SCALABILITY_FACTOR ;
/* Initialize the measure list */
@@ -140,8 +140,8 @@ int main ( int argc, char *argv[] )
/* Initialize output routine */
output_init();
- if ( CHILD_MAX > 0 )
- my_max = CHILD_MAX;
+ if ( MY_CHILD_MAX > 0 )
+ my_max = MY_CHILD_MAX;
pr = ( pid_t * ) calloc( 1 + my_max, sizeof( pid_t ) );
@@ -151,7 +151,7 @@ int main ( int argc, char *argv[] )
}
#if VERBOSE > 1
- output( "CHILD_MAX: %d\n", CHILD_MAX );
+ output( "CHILD_MAX: %d\n", MY_CHILD_MAX );
#endif
@@ -267,12 +267,12 @@ int main ( int argc, char *argv[] )
/* Parent */
nprocesses++;
- /* FAILED if nprocesses > CHILD_MAX */
+ /* FAILED if nprocesses > MY_CHILD_MAX */
if ( nprocesses > my_max )
{
errno = 0;
- if ( CHILD_MAX > 0 )
+ if ( MY_CHILD_MAX > 0 )
{
#if VERBOSE > 0
output( "WARNING! We were able to create more than CHILD_MAX processes\n" );
Home |
Main Index |
Thread Index |
Old Index