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
14fed9641096e27f79a0f2d9adfe9839dd8d11dc0fWanlong Gao * with this program; if not, write the Free Software Foundation, Inc.,
15fed9641096e27f79a0f2d9adfe9839dd8d11dc0fWanlong Gao * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1661037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao *
1737550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
1837550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
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.
2137550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
2261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * The following macros are defined here:
2337550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman * 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.
2937550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman *
3037550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman * Both three macros shall terminate the calling process.
3161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao * The testcase shall not terminate without calling one of those macros.
3237550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman *
3337550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman *
3461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao */
3537550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
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); }
4637550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
4761037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define FAILED(s) \
4861037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao { output("Test %s FAILED: %s\n", __FILE__, s); \
4961037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 	output_fini(); \
5061037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 	exit(PTS_FAIL); }
5137550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
5261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define PASSED \
5361037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao  output_fini(); \
5461037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao  exit(PTS_PASS);
5537550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
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}
6137550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
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); }
6837550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
6961037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao #define FAILED(s) \
7061037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao { output("Test FAILED: %s\n", s); \
7161037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao  output_fini(); \
7261037e1eb051a155908f1d038b5b156a3f661023Wanlong Gao 	exit(PTS_FAIL); }
7337550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
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