Home | History | Annotate | Download | only in mlockall
      1 /*
      2  *  This program is free software; you can redistribute it and/or modify
      3  *  it under the terms of the GNU General Public License version 2.
      4  *
      5  *  This program is distributed in the hope that it will be useful,
      6  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      7  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      8  *  GNU General Public License for more details.
      9  *
     10  * Test that mlockall return a value of zero upon successful completion.
     11  *
     12  */
     13 #include <sys/mman.h>
     14 #include <stdio.h>
     15 #include <errno.h>
     16 #include "posixtest.h"
     17 
     18 int main(void)
     19 {
     20 	int result;
     21 
     22 	result = mlockall(MCL_CURRENT);
     23 	if (result == 0 && errno == 0) {
     24 		printf("Test PASSED\n");
     25 		return PTS_PASS;
     26 	} else if (errno == 0) {
     27 		printf("mlockall did not return a value of zero\n");
     28 		return PTS_FAIL;
     29 	} else if (errno == EPERM) {
     30 		printf
     31 		    ("You don't have permission to lock your address space.\nTry to rerun this test as root.\n");
     32 		return PTS_UNRESOLVED;
     33 	}
     34 
     35 	perror("Unexpected error");
     36 	return PTS_UNRESOLVED;
     37 }
     38