blob: 0397d9e31613c0498a0180065d65f95b8d125306 [file] [log] [blame]
robbiewbb533ee2005-04-12 22:21:43 +00001/*
2 * Copyright (c) International Business Machines Corp., 2005
3 * Copyright (c) Wipro Technologies Ltd, 2005. All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 *
13 * You should have received a copy of the GNU General Public License along
Wanlong Gaofed96412012-10-24 10:10:29 +080014 * with this program; if not, write the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
robbiewbb533ee2005-04-12 22:21:43 +000016 *
17 */
18/**********************************************************
19 *
20 * TEST IDENTIFIER : getpagesize01
21 *
22 * EXECUTED BY : root / superuser
23 *
24 * TEST TITLE : Basic tests for getpagesize(2)
25 *
26 * TEST CASE TOTAL : 1
27 *
subrata_modak4bb656a2009-02-26 12:02:09 +000028 * AUTHOR : Prashant P Yendigeri
29 * <prashant.yendigeri@wipro.com>
robbiewbb533ee2005-04-12 22:21:43 +000030 * Robbie Williamson
31 * <robbiew@us.ibm.com>
32 *
33 * DESCRIPTION
34 * This is a Phase I test for the getpagesize(2) system call.
35 * It is intended to provide a limited exposure of the system call.
36 *
37 **********************************************************/
38
39#include <stdio.h>
40#include <unistd.h>
41#include <errno.h>
42
43#include "test.h"
robbiewbb533ee2005-04-12 22:21:43 +000044
vapieraa354722006-05-26 06:26:37 +000045void setup();
46void cleanup();
robbiewbb533ee2005-04-12 22:21:43 +000047
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020048char *TCID = "getpagesize01";
49int TST_TOTAL = 1;
robbiewbb533ee2005-04-12 22:21:43 +000050
subrata_modak56207ce2009-03-23 13:35:39 +000051int main(int ac, char **av)
robbiewbb533ee2005-04-12 22:21:43 +000052{
Cyril Hrubis89af32a2012-10-24 16:39:11 +020053 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020054 const char *msg;
robbiewbb533ee2005-04-12 22:21:43 +000055
56 int size, ret_sysconf;
57 /***************************************************************
58 * parse standard options
59 ***************************************************************/
Garrett Cooper45e285d2010-11-22 12:19:25 -080060 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -080061 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
robbiewbb533ee2005-04-12 22:21:43 +000062
subrata_modak56207ce2009-03-23 13:35:39 +000063 setup();
robbiewbb533ee2005-04-12 22:21:43 +000064
subrata_modak56207ce2009-03-23 13:35:39 +000065 for (lc = 0; TEST_LOOPING(lc); lc++) {
robbiewbb533ee2005-04-12 22:21:43 +000066
Caspar Zhangd59a6592013-03-07 14:59:12 +080067 tst_count = 0;
robbiewbb533ee2005-04-12 22:21:43 +000068
subrata_modak56207ce2009-03-23 13:35:39 +000069 TEST(getpagesize());
robbiewbb533ee2005-04-12 22:21:43 +000070
subrata_modak56207ce2009-03-23 13:35:39 +000071 if (TEST_RETURN == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +080072 tst_resm(TFAIL | TTERRNO, "getpagesize failed");
subrata_modak56207ce2009-03-23 13:35:39 +000073 continue; /* next loop for MTKERNEL */
74 }
robbiewbb533ee2005-04-12 22:21:43 +000075
Cyril Hrubise38b9612014-06-02 17:20:57 +020076 size = getpagesize();
77 tst_resm(TINFO, "Page Size is %d", size);
78 ret_sysconf = sysconf(_SC_PAGESIZE);
robbiewbb533ee2005-04-12 22:21:43 +000079#ifdef DEBUG
Cyril Hrubise38b9612014-06-02 17:20:57 +020080 tst_resm(TINFO,
81 "Checking whether getpagesize returned same as sysconf");
robbiewbb533ee2005-04-12 22:21:43 +000082#endif
Cyril Hrubise38b9612014-06-02 17:20:57 +020083 if (size == ret_sysconf)
84 tst_resm(TPASS,
85 "getpagesize - Page size returned %d",
86 ret_sysconf);
87 else
88 tst_resm(TFAIL,
89 "getpagesize - Page size returned %d",
90 ret_sysconf);
Garrett Cooper53740502010-12-16 00:04:01 -080091 }
robbiewbb533ee2005-04-12 22:21:43 +000092
subrata_modak56207ce2009-03-23 13:35:39 +000093 cleanup();
Garrett Cooperebf7df22010-12-19 01:52:15 -080094 tst_exit();
Garrett Cooper2c282152010-12-16 00:55:50 -080095}
robbiewbb533ee2005-04-12 22:21:43 +000096
Mike Frysingerc57fba52014-04-09 18:56:30 -040097void setup(void)
robbiewbb533ee2005-04-12 22:21:43 +000098{
Garrett Cooper2c282152010-12-16 00:55:50 -080099
subrata_modak56207ce2009-03-23 13:35:39 +0000100 tst_sig(NOFORK, DEF_HANDLER, cleanup);
robbiewbb533ee2005-04-12 22:21:43 +0000101
subrata_modak56207ce2009-03-23 13:35:39 +0000102 TEST_PAUSE;
Garrett Cooper2c282152010-12-16 00:55:50 -0800103}
robbiewbb533ee2005-04-12 22:21:43 +0000104
Mike Frysingerc57fba52014-04-09 18:56:30 -0400105void cleanup(void)
robbiewbb533ee2005-04-12 22:21:43 +0000106{
Chris Dearmanec6edca2012-10-17 19:54:01 -0700107}