robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 1 | /* |
| 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 Gao | fed9641 | 2012-10-24 10:10:29 +0800 | [diff] [blame] | 14 | * with this program; if not, write the Free Software Foundation, Inc., |
| 15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 16 | * |
| 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 28 | * AUTHOR : Prashant P Yendigeri |
| 29 | * <prashant.yendigeri@wipro.com> |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 30 | * 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" |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 44 | |
vapier | aa35472 | 2006-05-26 06:26:37 +0000 | [diff] [blame] | 45 | void setup(); |
| 46 | void cleanup(); |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 47 | |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 48 | char *TCID = "getpagesize01"; |
| 49 | int TST_TOTAL = 1; |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 50 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 51 | int main(int ac, char **av) |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 52 | { |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 53 | int lc; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 54 | const char *msg; |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 55 | |
| 56 | int size, ret_sysconf; |
| 57 | /*************************************************************** |
| 58 | * parse standard options |
| 59 | ***************************************************************/ |
Garrett Cooper | 45e285d | 2010-11-22 12:19:25 -0800 | [diff] [blame] | 60 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) |
Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 61 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 62 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 63 | setup(); |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 64 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 65 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 66 | |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 67 | tst_count = 0; |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 68 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 69 | TEST(getpagesize()); |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 70 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 71 | if (TEST_RETURN == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 72 | tst_resm(TFAIL | TTERRNO, "getpagesize failed"); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 73 | continue; /* next loop for MTKERNEL */ |
| 74 | } |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 75 | |
Cyril Hrubis | e38b961 | 2014-06-02 17:20:57 +0200 | [diff] [blame] | 76 | size = getpagesize(); |
| 77 | tst_resm(TINFO, "Page Size is %d", size); |
| 78 | ret_sysconf = sysconf(_SC_PAGESIZE); |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 79 | #ifdef DEBUG |
Cyril Hrubis | e38b961 | 2014-06-02 17:20:57 +0200 | [diff] [blame] | 80 | tst_resm(TINFO, |
| 81 | "Checking whether getpagesize returned same as sysconf"); |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 82 | #endif |
Cyril Hrubis | e38b961 | 2014-06-02 17:20:57 +0200 | [diff] [blame] | 83 | 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 Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 91 | } |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 92 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 93 | cleanup(); |
Garrett Cooper | ebf7df2 | 2010-12-19 01:52:15 -0800 | [diff] [blame] | 94 | tst_exit(); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 95 | } |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 96 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 97 | void setup(void) |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 98 | { |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 99 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 100 | tst_sig(NOFORK, DEF_HANDLER, cleanup); |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 101 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 102 | TEST_PAUSE; |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 103 | } |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 104 | |
Mike Frysinger | c57fba5 | 2014-04-09 18:56:30 -0400 | [diff] [blame] | 105 | void cleanup(void) |
robbiew | bb533ee | 2005-04-12 22:21:43 +0000 | [diff] [blame] | 106 | { |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 107 | } |