changed [skip]ped tests to start working, even with the large LINK_MAX

This commit is contained in:
Ben Gras 2005-05-09 13:39:23 +00:00
parent 3afa217777
commit 9d93a8eade
3 changed files with 22 additions and 54 deletions

View file

@ -452,7 +452,7 @@ void test20g()
/* Test link and unlink. */
int i, fd;
struct stat stbuf;
char name[4];
char name[20];
subtest = 9;
@ -522,27 +522,19 @@ void test20g()
if (unlink("L3") != 0) e(49);
/* L1 exists at this point. Test creating too many links. */
if (LINK_MAX > 127) {
printf("[skip] "); /* takes too many resources */
} else {
name[0] = 'L';
name[1] = 'x';
name[2] = 1;
name[3] = 0;
for (i = 2; i <= LINK_MAX; i++) {
sprintf(name, "Lx%d", i);
if (link("L1", name) != 0) e(50);
name[2]++;
}
if (stat("L1", &stbuf) != 0) e(51);
if (stbuf.st_nlink != LINK_MAX) e(52);
if (link("L1", "L2") != -1) e(53);
if (errno != EMLINK) e(54);
name[2] = 1;
for (i = 2; i <= LINK_MAX; i++) {
sprintf(name, "Lx%d", i);
if (unlink(name) != 0) e(55);
name[2]++;
}
}
if (stat("L1", &stbuf) != 0) e(56);
if (stbuf.st_nlink != 1) e(57);

View file

@ -119,7 +119,7 @@ void test26a()
void test26b()
{
register int nlink;
char *bar = "bar.xxxxx"; /* xxxxx will hold a number up to 99999 */
char bar[30];
struct stat st, st2;
subtest = 2;
@ -129,16 +129,8 @@ void test26b()
/* Test what happens if we make LINK_MAX number of links. */
System("touch foo");
if (LINK_MAX > 127) {
printf("[skip] "); /* takes too many resources */
} else {
if (LINK_MAX >= 99999) e(1); /* check "xxxxx" are enough */
for (nlink = 2; nlink <= LINK_MAX; nlink++) {
bar[4] = (char) ((nlink / 10000) % 10) + '0';
bar[5] = (char) ((nlink / 1000) % 10) + '0';
bar[6] = (char) ((nlink / 100) % 10) + '0';
bar[7] = (char) ((nlink / 10) % 10) + '0';
bar[8] = (char) (nlink % 10) + '0';
sprintf(bar, "bar.%d", nlink);
if (link("foo", bar) != 0) e(2);
Stat(bar, &st);
if (st.st_nlink != nlink) e(3);
@ -150,11 +142,7 @@ if (LINK_MAX > 127) {
Stat("foo", &st);
if (st.st_nlink != LINK_MAX) e(5);
for (nlink = 2; nlink <= LINK_MAX; nlink++) {
bar[4] = (char) ((nlink / 10000) % 10) + '0';
bar[5] = (char) ((nlink / 1000) % 10) + '0';
bar[6] = (char) ((nlink / 100) % 10) + '0';
bar[7] = (char) ((nlink / 10) % 10) + '0';
bar[8] = (char) (nlink % 10) + '0';
sprintf(bar, "bar.%d", nlink);
Stat(bar, &st2);
if (!stateq(&st, &st2)) e(6);
}
@ -167,16 +155,13 @@ if (LINK_MAX > 127) {
/* Now unlink() the bar.### files */
for (nlink = LINK_MAX; nlink >= 2; nlink--) {
bar[4] = (char) ((nlink / 100) % 10) + '0';
bar[5] = (char) ((nlink / 10) % 10) + '0';
bar[6] = (char) (nlink % 10) + '0';
sprintf(bar, "bar.%d", nlink);
Stat(bar, &st);
if (st.st_nlink != nlink) e(10);
Stat("foo", &st2);
if (!stateq(&st, &st2)) e(11);
if (unlink(bar) != 0) e(12);
}
}
Stat("foo", &st);
if (st.st_nlink != 1) e(13); /* number of links back to 1 */

View file

@ -174,7 +174,7 @@ void test28b()
int other = 0, dot = 0, dotdot = 0; /* dirent counters */
int rmdir_result; /* tmp var */
nlink_t nlink;
static char bar[] = "foo/bar.xxxxx";
static char bar[20];
int stat_loc;
subtest = 2;
@ -190,8 +190,6 @@ void test28b()
if (rmdir("/.././/././/tmp/foo///////////////") != 0) e(6);
if (rmdir("/tmp/foo") != -1) e(7); /* try again */
if (LINK_MAX >= 99999) e(8); /* "xxxxx" in filename not long inough */
/* Test max path ed. */
if (mkdir(MaxName, 0777) != 0) e(9); /* make dir MaxName */
if (rmdir(MaxName) != 0) e(10); /* and remove it */
@ -211,31 +209,21 @@ void test28b()
if (errno != ENAMETOOLONG) e(22);
/* Test what happens if the parent link count > LINK_MAX. */
if (mkdir("foo", 0777) != 0) e(23); /* make foo */
if (LINK_MAX > 127) {
printf("[skip] "); /* takes to many resources */
} else {
for (nlink = 2; nlink < LINK_MAX; nlink++) { /* make all */
bar[8] = (char) ((nlink / 10000) % 10) + '0';
bar[9] = (char) ((nlink / 1000) % 10) + '0';
bar[10] = (char) ((nlink / 100) % 10) + '0';
bar[11] = (char) ((nlink / 10) % 10) + '0';
bar[12] = (char) (nlink % 10) + '0';
if (mkdir(bar, 0777) != 0) {
printf("nlink=%u\n", nlink);
e(24);
}
if (mkdir("foo", 0777) != 0) e(23);
System("touch foo/xyzzy");
for (nlink = 1; nlink < LINK_MAX; nlink++) { /* make all */
sprintf(bar, "foo/bar.%d", nlink);
if (link("foo/xyzzy", bar) != 0) e(24);
}
if (stat("foo", &st) != 0) e(25); /* foo now */
if (stat("foo/xyzzy", &st) != 0) e(25); /* foo now */
if (st.st_nlink != LINK_MAX) e(26); /* is full */
if (mkdir("foo/nono", 0777) != -1) e(27); /* no more */
if (link("foo/xyzzy", "nono") != -1) e(27); /* no more */
if (errno != EMLINK) e(28); /* entrys. */
System("rm -rf foo/nono"); /* Just in case. */
/* Test if rmdir removes only empty dirs */
if (rmdir("foo") != -1) e(29);/* not empty */
if (errno != EEXIST && errno != ENOTEMPTY) e(30);
}
/* Test if rmdir removes a dir with an empty file (it shouldn't.) */
System("rm -rf foo"); /* cleanup */
if (mkdir("foo", 0777) != 0) e(31);
@ -262,9 +250,12 @@ if (LINK_MAX > 127) {
#endif
/* See if ".." and "." are removed from the dir, and if it is
* unwriteable * Note, we can not remove any files in the PARENT
* process, because this * will make readdir unpredicatble. (see
* 1003.1 page 84 line 30.) However * removal of the directory is
* unwriteable
* Note, we can not remove any files in the PARENT
* process, because this
* will make readdir unpredicatble. (see
* 1003.1 page 84 line 30.) However
* removal of the directory is
* not specified in the standard.
*/
System("rm -rf /tmp/sema[12].07");