testfrmw.h revision 61037e1eb051a155908f1d038b5b156a3f661023
161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao/* 261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * Copyright (c) 2004, Bull S.A.. All rights reserved. 361037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * Created by: Sebastien Decugis 461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 561037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * This program is free software; you can redistribute it and/or modify it 661037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * under the terms of version 2 of the GNU General Public License as 761037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * published by the Free Software Foundation. 861037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * 961037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * This program is distributed in the hope that it would be useful, but 1061037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * WITHOUT ANY WARRANTY; without even the implied warranty of 1161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * 1361037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * You should have received a copy of the GNU General Public License along 1461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * with this program; if not, write the Free Software Foundation, Inc., 59 1561037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * Temple Place - Suite 330, Boston MA 02111-1307, USA. 1661037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * 1761037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 1861037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 1961037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * This file is a wrapper to use the tests from the NPTL Test & Trace Project 2061037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * with either the Linux Test Project or the Open POSIX Test Suite. 2161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 2261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * The following macros are defined here: 2361037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * UNRESOLVED(ret, descr); 2461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * where descr is a description of the error and ret is an int (error code for example) 2561037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * FAILED(descr); 2661037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * where descr is a short text saying why the test has failed. 2761037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * PASSED(); 2861037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * No parameter. 2961037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * 3061037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * Both three macros shall terminate the calling process. 3161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * The testcase shall not terminate without calling one of those macros. 3261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * 3361037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * 3461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao */ 3561037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 3661037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao#include "posixtest.h" 3761037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao#include <string.h> /* for the strerror() routine */ 3861037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 3961037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 4061037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao#ifdef __GNUC__ /* We are using GCC */ 4161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 4261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define UNRESOLVED(x, s) \ 4361037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao { output("Test %s unresolved: got %i (%s) on line %i (%s)\n", __FILE__, x, strerror(x), __LINE__, s); \ 4461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao output_fini(); \ 4561037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao exit(PTS_UNRESOLVED); } 4661037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 4761037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define FAILED(s) \ 4861037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao { output("Test %s FAILED: %s\n", __FILE__, s); \ 4961037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao output_fini(); \ 5061037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao exit(PTS_FAIL); } 5161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 5261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define PASSED \ 5361037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao output_fini(); \ 5461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao exit(PTS_PASS); 5561037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 5661037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define UNTESTED(s) \ 5761037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao{ output("File %s cannot test: %s\n", __FILE__, s); \ 5861037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao output_fini(); \ 5961037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao exit(PTS_UNTESTED); \ 6061037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao} 6161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 6261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao#else /* not using GCC */ 6361037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 6461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define UNRESOLVED(x, s) \ 6561037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao { output("Test unresolved: got %i (%s) on line %i (%s)\n", x, strerror(x), __LINE__, s); \ 6661037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao output_fini(); \ 6761037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao exit(PTS_UNRESOLVED); } 6861037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 6961037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define FAILED(s) \ 7061037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao { output("Test FAILED: %s\n", s); \ 7161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao output_fini(); \ 7261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao exit(PTS_FAIL); } 7361037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 7461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define PASSED \ 7561037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao output_fini(); \ 7661037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao exit(PTS_PASS); 7761037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 7861037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define UNTESTED(s) \ 7961037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao{ output("Unable to test: %s\n", s); \ 8061037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao output_fini(); \ 8161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao exit(PTS_UNTESTED); \ 8261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao} 8361037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 8461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao#endif 8561037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 86