12c28215423293e443469a07ae7011135d058b671Garrett Cooper/* 20dc076565f772bb1953209fb69ea150b494aaa40robbiew * Copyright (c) 2002, Intel Corporation. All rights reserved. 30dc076565f772bb1953209fb69ea150b494aaa40robbiew * Created by: bing.wei.liu REMOVE-THIS AT intel DOT com 40dc076565f772bb1953209fb69ea150b494aaa40robbiew * This file is licensed under the GPL license. For the full content 52c28215423293e443469a07ae7011135d058b671Garrett Cooper * of this license, see the COPYING file at the top level of this 60dc076565f772bb1953209fb69ea150b494aaa40robbiew * source tree. 70dc076565f772bb1953209fb69ea150b494aaa40robbiew 80dc076565f772bb1953209fb69ea150b494aaa40robbiew * Test that pthread_cond_init() 90dc076565f772bb1953209fb69ea150b494aaa40robbiew * Upon succesful completion, it shall return a 0 100dc076565f772bb1953209fb69ea150b494aaa40robbiew * 110dc076565f772bb1953209fb69ea150b494aaa40robbiew */ 120dc076565f772bb1953209fb69ea150b494aaa40robbiew 130dc076565f772bb1953209fb69ea150b494aaa40robbiew#include <pthread.h> 140dc076565f772bb1953209fb69ea150b494aaa40robbiew#include <stdio.h> 155e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale#include <string.h> 160dc076565f772bb1953209fb69ea150b494aaa40robbiew#include <errno.h> 170dc076565f772bb1953209fb69ea150b494aaa40robbiew#include "posixtest.h" 180dc076565f772bb1953209fb69ea150b494aaa40robbiew 195e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale#define ERR_MSG(f, rc) printf("Failed: func: %s rc: %s (%u)\n", \ 205e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale f, strerror(rc), rc) 215e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale 225e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morrealeint main(void) 230dc076565f772bb1953209fb69ea150b494aaa40robbiew{ 240dc076565f772bb1953209fb69ea150b494aaa40robbiew pthread_condattr_t condattr; 255e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale pthread_cond_t cond; 260dc076565f772bb1953209fb69ea150b494aaa40robbiew int rc; 275e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale int status = PTS_UNRESOLVED; 285e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale char *label; 290dc076565f772bb1953209fb69ea150b494aaa40robbiew 305e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale label = "pthread_condattr_init()"; 315e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale rc = pthread_condattr_init(&condattr); 325e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale if (rc) 335e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale goto done; 342c28215423293e443469a07ae7011135d058b671Garrett Cooper 355e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale label = "pthread_cond_init()"; 365e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale rc = pthread_cond_init(&cond, &condattr); 375e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale switch (rc) { 385e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale case 0: 395e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale break; 405e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale case ENOMEM: 415e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale case EINVAL: 425e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale case EBUSY: 435e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale case EAGAIN: 445e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale status = PTS_UNRESOLVED; 455e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale goto done; 465e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale default: 475e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale status = PTS_FAIL; 485e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale goto done; 490dc076565f772bb1953209fb69ea150b494aaa40robbiew } 502c28215423293e443469a07ae7011135d058b671Garrett Cooper 51de55e5ac14dc3e683117ae84bad34944fa7c38c6Cyril Hrubis printf("Test PASSED\n"); 525e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale return PTS_PASS; 530dc076565f772bb1953209fb69ea150b494aaa40robbiew 545e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morrealedone: 555e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale ERR_MSG(label, rc); 565e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale return status; 575e6c18c52372e1d2ea35236120a3fc6bbaa6ba5aPeter W Morreale} 58