/* setup() - performs all ONE TIME setup for this test */ void setup() { tst_sig(FORK, DEF_HANDLER, cleanup); /* set the expected errnos... */ TEST_EXP_ENOS(exp_enos); /* Check whether we are root */ if (geteuid() != 0) { tst_brkm(TBROK, NULL, "Test must be run as root"); } TEST_PAUSE; tst_tmpdir(); if (tst_is_cwd_tmpfs()) { tst_brkm(TCONF, cleanup, "Cannot do swapon on a file located on a tmpfs filesystem"); } if (tst_is_cwd_nfs()) { tst_brkm(TCONF, cleanup, "Cannot do swapon on a file located on a nfs filesystem"); } if (!tst_cwd_has_free(65536)) { tst_brkm(TBROK, cleanup, "Insufficient disk space to create swap file"); } /*create file */ if (system ("dd if=/dev/zero of=swapfile01 bs=1024 count=65536 > tmpfile" " 2>&1") != 0) { tst_brkm(TBROK, cleanup, "Failed to create file for swap"); } /* make above file a swap file */ if (system("mkswap ./swapfile01 > tmpfile 2>&1") != 0) { tst_brkm(TBROK, cleanup, "Failed to make swapfile"); } if (syscall(__NR_swapon, "./swapfile01", 0) != 0) { tst_brkm(TBROK, cleanup, "Failed to turn on the swap file." " skipping the test iteration"); } need_swapfile_cleanup = 1; }
/* setup() - performs all ONE TIME setup for this test */ void setup() { tst_sig(FORK, DEF_HANDLER, cleanup); /* Check whether we are root */ if (geteuid() != 0) { tst_brkm(TBROK, NULL, "Test must be run as root"); } TEST_PAUSE; tst_tmpdir(); if (tst_is_cwd_tmpfs()) { tst_brkm(TCONF, cleanup, "Cannot do swapon on a file located on a tmpfs filesystem"); } if (tst_is_cwd_nfs()) { tst_brkm(TCONF, cleanup, "Cannot do swapon on a file located on a nfs filesystem"); } if (!tst_cwd_has_free(65536)) { tst_brkm(TBROK, cleanup, "Insufficient disk space to create swap file"); } /*create file */ if (system ("dd if=/dev/zero of=swapfile01 bs=1024 count=65536 > tmpfile" " 2>&1 ") != 0) { tst_brkm(TBROK, cleanup, "Failed to create file for swap"); } /* make above file a swap file */ if (system("mkswap swapfile01 > tmpfile 2>&1") != 0) { tst_brkm(TBROK, cleanup, "Failed to make swapfile"); } }