Patch by Vasilis Kaoutsis:

* Added pthreads posix test suite tests to run script and image.
* Improved output for said tests.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23002 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-11-26 23:25:59 +00:00
parent da744139fa
commit 04f08f4f65
13 changed files with 98 additions and 59 deletions

View File

@ -446,6 +446,17 @@ if $(HAIKU_ADD_POSIX_TEST_SUITE_TO_IMAGE) {
AddFilesToHaikuImage home posixtestsuite conformance interfaces sigset
: sigset_1-1 sigset_2-1 sigset_3-1 sigset_4-1 sigset_5-1 sigset_6-1
sigset_7-1 sigset_8-1 sigset_9-1 sigset_10-1 ;
# add pthreads tests
AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_getspecific
: pthread_getspecific_1-1 pthread_getspecific_3-1 ;
AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_key_create
: pthread_key_create_1-1 pthread_key_create_1-2 pthread_key_create_2-1
pthread_key_create_3-1 ;
AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_key_delete
: pthread_key_delete_1-1 pthread_key_delete_1-2 pthread_key_delete_2-1 ;
AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_setspecific
: pthread_setspecific_1-1 pthread_setspecific_1-2 ;
}

View File

@ -37,13 +37,13 @@ int main()
{
if(pthread_key_create(&keys[i], NULL) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_getspecific_1-1 Error: pthread_key_create() failed\n");
return PTS_UNRESOLVED;
} else
{
if(pthread_setspecific(keys[i], (void *)(long)(i + KEY_VALUE)) != 0)
{
printf("Error: pthread_setspecific() failed\n");
printf("pthread_getspecific_1-1 Error: pthread_setspecific() failed\n");
return PTS_UNRESOLVED;
}
@ -55,18 +55,18 @@ int main()
rc = pthread_getspecific(keys[i]);
if(rc != (void *)(long)(i + KEY_VALUE))
{
printf("Test FAILED: Did not return correct value of thread-specific key, expected %d, but got %ld\n", (i + KEY_VALUE), (long)rc);
printf("pthread_getspecific_1-1 Test FAILED: Did not return correct value of thread-specific key, expected %d, but got %ld\n", (i + KEY_VALUE), (long)rc);
return PTS_FAIL;
} else
{
if(pthread_key_delete(keys[i]) != 0)
{
printf("Error: pthread_key_delete() failed\n");
printf("pthread_getspecific_1-1 Error: pthread_key_delete() failed\n");
return PTS_UNRESOLVED;
}
}
}
printf("Test PASSED\n");
printf("pthread_getspecific_1-1: Test PASSED\n");
return PTS_PASS;
}

View File

@ -30,23 +30,23 @@ int main()
if(pthread_key_create(&key, NULL) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_getspecific_3-1 Error: pthread_key_create() failed\n");
return PTS_UNRESOLVED;
}
rc = pthread_getspecific(key);
if(rc != NULL)
{
printf("Test FAILED: Did not return correct value, expected NULL, but got %ld\n", (long)rc);
printf("pthread_getspecific_3-1 Test FAILED: Did not return correct value, expected NULL, but got %ld\n", (long)rc);
return PTS_FAIL;
}
if(pthread_key_delete(key) != 0)
{
printf("Error: pthread_key_delete() failed\n");
printf("pthread_getspecific_3-1 Error: pthread_key_delete() failed\n");
return PTS_UNRESOLVED;
}
printf("Test PASSED\n");
printf("pthread_getspecific_3-1: Test PASSED\n");
return PTS_PASS;
}

View File

@ -40,13 +40,13 @@ int main()
{
if(pthread_key_create(&keys[i], NULL) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_key_create_1-1 Error: pthread_key_create() failed\n");
return PTS_UNRESOLVED;
} else
{
if(pthread_setspecific(keys[i], (void *)(long)(i + KEY_VALUE)) != 0)
{
printf("Error: pthread_setspecific() failed\n");
printf("pthread_key_create_1-1 Error: pthread_setspecific() failed\n");
return PTS_UNRESOLVED;
}
@ -58,18 +58,18 @@ int main()
rc = pthread_getspecific(keys[i]);
if(rc != (void *)(long)(i + KEY_VALUE))
{
printf("Test FAILED: Did not return correct value of thread-specific key, expected %ld, but got %ld\n", (long)(i + KEY_VALUE), (long)rc);
printf("pthread_key_create_1-1 Test FAILED: Did not return correct value of thread-specific key, expected %ld, but got %ld\n", (long)(i + KEY_VALUE), (long)rc);
return PTS_FAIL;
} else
{
if(pthread_key_delete(keys[i]) != 0)
{
printf("Error: pthread_key_delete() failed\n");
printf("pthread_key_create_1-1 Error: pthread_key_delete() failed\n");
return PTS_UNRESOLVED;
}
}
}
printf("Test PASSED\n");
printf("pthread_key_create_1-1: Test PASSED\n");
return PTS_PASS;
}

View File

@ -36,7 +36,7 @@ void *a_thread_func()
/* Set the key to KEY_VALUE */
if(pthread_setspecific(keys[i], (void *)(KEY_VALUE)) != 0)
{
printf("Error: pthread_setspecific() failed\n");
printf("pthread_key_create_1-2 Error: pthread_setspecific() failed\n");
pthread_exit((void*)PTS_FAIL);
}
@ -53,7 +53,7 @@ int main()
{
if(pthread_key_create(&keys[i], NULL) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_key_create_1-2 Error: pthread_key_create() failed\n");
return PTS_UNRESOLVED;
}
}
@ -65,24 +65,24 @@ int main()
/* Create a thread */
if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0)
{
perror("Error creating thread\n");
perror("pthread_key_create_1-2 Error creating thread\n");
return PTS_UNRESOLVED;
}
/* Wait for thread to end */
if(pthread_join(new_th, &value_ptr) != 0)
{
perror("Error in pthread_join\n");
perror("pthread_key_create_1-2 Error in pthread_join\n");
return PTS_UNRESOLVED;
}
if(value_ptr == (void*) PTS_FAIL)
{
printf("Test FAILED: Could not use a certain key value to set for many keys\n");
printf("pthread_key_create_1-2: Test FAILED: Could not use a certain key value to set for many keys\n");
return PTS_FAIL;
}
}
printf("Test PASSED\n");
printf("pthread_key_create_1-2: Test PASSED\n");
return PTS_PASS;
}

View File

@ -33,13 +33,13 @@ int main()
rc = pthread_getspecific(key);
if(rc != NULL)
{
printf("Test FAILED\n");
printf("pthread_key_create_2-1 Test FAILED\n");
return PTS_FAIL;
}
if(pthread_key_create(&key, NULL) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_key_create_2-1 pthread_key_create_2-1 Error: pthread_key_create() failed\n");
return PTS_UNRESOLVED;
} else
{
@ -48,12 +48,12 @@ int main()
rc = pthread_getspecific(key);
if(rc != NULL)
{
printf("Test FAILED\n");
printf("pthread_key_create_2-1 Test FAILED\n");
return PTS_FAIL;
}
}
printf("Test PASSED\n");
printf("pthread_key_create_2-1: Test PASSED\n");
return PTS_PASS;
}

View File

@ -44,7 +44,7 @@ void *a_thread_func()
/* Set the value of the key to a value */
if(pthread_setspecific(key, (void *)(KEY_VALUE)) != 0)
{
printf("Error: pthread_setspecific() failed\n");
printf("pthread_key_create_3-1 Error: pthread_setspecific() failed\n");
pthread_exit((void*) PTS_UNRESOLVED);
}
@ -62,31 +62,31 @@ int main()
/* Create a key with a destructor function */
if(pthread_key_create(&key, dest_func) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_key_create_3-1 Error: pthread_key_create() failed\n");
pthread_exit((void*) PTS_UNRESOLVED);
}
/* Create a thread */
if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0)
{
perror("Error creating thread\n");
perror("pthread_key_create_3-1 Error creating thread\n");
return PTS_UNRESOLVED;
}
/* Wait for the thread's return */
if(pthread_join(new_th, NULL) != 0)
{
perror("Error in pthread_join()\n");
perror("pthread_key_create_3-1 Error in pthread_join()\n");
return PTS_UNRESOLVED;
}
/* Check if the destructor was called */
if(dest_cnt == 0)
{
printf("Test FAILED: Destructor not called\n");
printf("pthread_key_create_3-1 Test FAILED: Destructor not called\n");
return PTS_FAIL;
}
printf("Test PASSED\n");
printf("pthread_key_create_3-1: Test PASSED\n");
return PTS_PASS;
}

View File

@ -39,18 +39,18 @@ int main()
{
if(pthread_key_create(&keys[i], NULL) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_key_delete_1-1 Error: pthread_key_create() failed\n");
return PTS_UNRESOLVED;
}
if(pthread_key_delete(keys[i]) != 0)
{
printf("Test FAILED\n");
printf("pthread_key_delete_1-1 Test FAILED\n");
return PTS_FAIL;
}
}
printf("Test PASSED\n");
printf("pthread_key_delete_1-1: Test PASSED\n");
return PTS_PASS;
}

View File

@ -40,23 +40,23 @@ int main()
{
if(pthread_key_create(&keys[i], NULL) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_key_delete_1-2 Error: pthread_key_create() failed\n");
return PTS_UNRESOLVED;
}
if(pthread_setspecific(keys[i], (void*)(long)(KEY_VALUE + i)) != 0)
{
printf("Error: pthread_setspecific failed\n");
printf("pthread_key_delete_1-2 Error: pthread_setspecific failed\n");
return PTS_UNRESOLVED;
}
if(pthread_key_delete(keys[i]) != 0)
{
printf("Test FAILED\n");
printf("pthread_key_delete_1-2 Test FAILED\n");
return PTS_FAIL;
}
}
printf("Test PASSED\n");
printf("pthread_key_delete_1-2: Test PASSED\n");
return PTS_PASS;
}

View File

@ -47,7 +47,7 @@ void *a_thread_func()
/* Set the value of the key to a value */
if(pthread_setspecific(key, (void *)(KEY_VALUE)) != 0)
{
printf("Error: pthread_setspecific() failed\n");
printf("pthread_key_delete_2-1 Error: pthread_setspecific() failed\n");
pthread_exit((void*) PTS_UNRESOLVED);
}
@ -65,21 +65,21 @@ int main()
/* Create a key with a destructor function */
if(pthread_key_create(&key, dest_func) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_key_delete_2-1 Error: pthread_key_create() failed\n");
pthread_exit((void*) PTS_UNRESOLVED);
}
/* Create a thread */
if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0)
{
perror("Error creating thread\n");
perror("pthread_key_delete_2-1 Error creating thread\n");
return PTS_UNRESOLVED;
}
/* Wait for the thread's return */
if(pthread_join(new_th, NULL) != 0)
{
perror("Error in pthread_join()\n");
perror("pthread_key_delete_2-1 Error in pthread_join()\n");
return PTS_UNRESOLVED;
}
@ -89,15 +89,15 @@ int main()
{
if(dest_cnt == 0)
{
printf("Error calling the key destructor function\n");
printf("pthread_key_delete_2-1 Error calling the key destructor function\n");
return PTS_UNRESOLVED;
} else
{
printf("Test FAILED: pthread_key_delete failed to be called from the destructor function\n");
printf("pthread_key_delete_2-1 Test FAILED: pthread_key_delete failed to be called from the destructor function\n");
return PTS_FAIL;
}
}
printf("Test PASSED\n");
printf("pthread_key_delete_2-1: Test PASSED\n");
return PTS_PASS;
}

View File

@ -38,13 +38,13 @@ int main()
{
if(pthread_key_create(&keys[i], NULL) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_setspecific_1-1 Error: pthread_key_create() failed\n");
return PTS_UNRESOLVED;
} else
{
if(pthread_setspecific(keys[i], (void *)(long)(i + KEY_VALUE)) != 0)
{
printf("Test FAILED: Could not set the value of the key to %d\n", (i + KEY_VALUE));
printf("pthread_setspecific_1-1 Test FAILED: Could not set the value of the key to %d\n", (i + KEY_VALUE));
return PTS_FAIL;
}
@ -56,18 +56,18 @@ int main()
rc = pthread_getspecific(keys[i]);
if(rc != (void *)(long)(i + KEY_VALUE))
{
printf("Test FAILED: Did not return correct value of thread-specific key, expected %ld, but got %ld\n", (long)(i + KEY_VALUE), (long)rc);
printf("pthread_setspecific_1-1 Test FAILED: Did not return correct value of thread-specific key, expected %ld, but got %ld\n", (long)(i + KEY_VALUE), (long)rc);
return PTS_FAIL;
} else
{
if(pthread_key_delete(keys[i]) != 0)
{
printf("Error: pthread_key_delete() failed\n");
printf("pthread_setspecific_1-1 Error: pthread_key_delete() failed\n");
return PTS_UNRESOLVED;
}
}
}
printf("Test PASSED\n");
printf("pthread_setspecific_1-1: Test PASSED\n");
return PTS_PASS;
}

View File

@ -40,7 +40,7 @@ void *a_thread_func()
* that we bind for the main thread) */
if(pthread_setspecific(key, (void *)(KEY_VALUE_2)) != 0)
{
printf("Test FAILED: Could not set the value of the key to %d\n", (KEY_VALUE_2));
printf("pthread_setspecific_1-2 Test FAILED: Could not set the value of the key to %d\n", (KEY_VALUE_2));
pthread_exit((void*)PTS_FAIL);
return NULL;
}
@ -60,21 +60,21 @@ int main()
/* Create the key */
if(pthread_key_create(&key, NULL) != 0)
{
printf("Error: pthread_key_create() failed\n");
printf("pthread_setspecific_1-2 Error: pthread_key_create() failed\n");
return PTS_UNRESOLVED;
}
/* Bind a value for this main thread */
if(pthread_setspecific(key, (void *)(KEY_VALUE_1)) != 0)
{
printf("Test FAILED: Could not set the value of the key to %d\n", (KEY_VALUE_1));
printf("pthread_setspecific_1-2 Test FAILED: Could not set the value of the key to %d\n", (KEY_VALUE_1));
return PTS_FAIL;
}
/* Create another thread. This thread will also bind a value to the key */
if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0)
{
printf("Error: in pthread_create()\n");
printf("pthread_setspecific_1-2 Error: in pthread_create()\n");
return PTS_UNRESOLVED;
}
@ -88,16 +88,16 @@ int main()
* thread, they should be different. */
if(rc1 != (void *)(KEY_VALUE_1))
{
printf("Test FAILED: Incorrect value bound to key, expected %d, got %ld\n", KEY_VALUE_1, (long)rc1);
printf("pthread_setspecific_1-2 Test FAILED: Incorrect value bound to key, expected %d, got %ld\n", KEY_VALUE_1, (long)rc1);
return PTS_FAIL;
}
if(rc2 != (void *)(KEY_VALUE_2))
{
printf("Test FAILED: Incorrect value bound to key, expected %d, got %ld\n", KEY_VALUE_2, (long)rc2);
printf("pthread_setspecific_1-2 Test FAILED: Incorrect value bound to key, expected %d, got %ld\n", KEY_VALUE_2, (long)rc2);
return PTS_FAIL;
}
printf("Test PASSED\n");
printf("pthread_setspecific_1-2: Test PASSED\n");
return PTS_PASS;
}

View File

@ -30,7 +30,8 @@ standard_tests()
conformance/interfaces/difftime/difftime_1-1
echo ""
echo "fork()"
conformance/interfaces/fork/fork_3-1
# conformance/interfaces/fork/fork_3-1
echo "fork_3-1: FIXME : test sometimes fails, see bug #1639"
conformance/interfaces/fork/fork_4-1
conformance/interfaces/fork/fork_6-1
conformance/interfaces/fork/fork_8-1
@ -46,6 +47,32 @@ asynchronous_input_output_tests()
}
threads_tests()
{
echo "pthread_getspecific()"
conformance/interfaces/pthread_getspecific/pthread_getspecific_1-1
conformance/interfaces/pthread_getspecific/pthread_getspecific_3-1
echo ""
echo "pthread_key_create()"
conformance/interfaces/pthread_key_create/pthread_key_create_1-1
# conformance/interfaces/pthread_key_create/pthread_key_create_1-2
echo "pthread_key_create_1-2: FIXME: test fails, see bug #1644"
# conformance/interfaces/pthread_key_create/pthread_key_create_2-1
echo "pthread_key_create_2-1: FIXME: test invokes the debugger, see bug #1646"
conformance/interfaces/pthread_key_create/pthread_key_create_3-1
echo ""
echo "pthread_key_delete()"
conformance/interfaces/pthread_key_delete/pthread_key_delete_1-1
conformance/interfaces/pthread_key_delete/pthread_key_delete_1-2
# conformance/interfaces/pthread_key_delete/pthread_key_delete_2-1
echo "pthread_key_delete_2-1: FIXME: test blocks, see bug #1642"
echo ""
echo "pthread_setspecific()"
conformance/interfaces/pthread_setspecific/pthread_setspecific_1-1
conformance/interfaces/pthread_setspecific/pthread_setspecific_1-2
}
signals_tests()
{
echo "kill()"
@ -112,6 +139,7 @@ all_tests()
standard_tests
asynchronous_input_output_tests
signals_tests
threads_tests
}
@ -135,7 +163,7 @@ sleep 1
#TODO sem*
;;
THR) echo "Executing threads tests"
#TODO pthread_*
threads_tests
;;
TMR) echo "Executing timers and clocks tests"
#TODO time* *time clock* nanosleep
@ -155,4 +183,4 @@ sleep 1
esac
echo "**** Tests Complete ****"
echo "**** Tests Completed ****"