changed [skip]ped tests to start working, even with the large LINK_MAX
This commit is contained in:
parent
3afa217777
commit
9d93a8eade
@ -452,7 +452,7 @@ void test20g()
|
|||||||
/* Test link and unlink. */
|
/* Test link and unlink. */
|
||||||
int i, fd;
|
int i, fd;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
char name[4];
|
char name[20];
|
||||||
|
|
||||||
subtest = 9;
|
subtest = 9;
|
||||||
|
|
||||||
@ -522,27 +522,19 @@ void test20g()
|
|||||||
if (unlink("L3") != 0) e(49);
|
if (unlink("L3") != 0) e(49);
|
||||||
|
|
||||||
/* L1 exists at this point. Test creating too many links. */
|
/* 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++) {
|
for (i = 2; i <= LINK_MAX; i++) {
|
||||||
|
sprintf(name, "Lx%d", i);
|
||||||
if (link("L1", name) != 0) e(50);
|
if (link("L1", name) != 0) e(50);
|
||||||
name[2]++;
|
|
||||||
}
|
}
|
||||||
if (stat("L1", &stbuf) != 0) e(51);
|
if (stat("L1", &stbuf) != 0) e(51);
|
||||||
if (stbuf.st_nlink != LINK_MAX) e(52);
|
if (stbuf.st_nlink != LINK_MAX) e(52);
|
||||||
if (link("L1", "L2") != -1) e(53);
|
if (link("L1", "L2") != -1) e(53);
|
||||||
if (errno != EMLINK) e(54);
|
if (errno != EMLINK) e(54);
|
||||||
name[2] = 1;
|
|
||||||
for (i = 2; i <= LINK_MAX; i++) {
|
for (i = 2; i <= LINK_MAX; i++) {
|
||||||
|
sprintf(name, "Lx%d", i);
|
||||||
if (unlink(name) != 0) e(55);
|
if (unlink(name) != 0) e(55);
|
||||||
name[2]++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat("L1", &stbuf) != 0) e(56);
|
if (stat("L1", &stbuf) != 0) e(56);
|
||||||
if (stbuf.st_nlink != 1) e(57);
|
if (stbuf.st_nlink != 1) e(57);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ void test26a()
|
|||||||
void test26b()
|
void test26b()
|
||||||
{
|
{
|
||||||
register int nlink;
|
register int nlink;
|
||||||
char *bar = "bar.xxxxx"; /* xxxxx will hold a number up to 99999 */
|
char bar[30];
|
||||||
struct stat st, st2;
|
struct stat st, st2;
|
||||||
|
|
||||||
subtest = 2;
|
subtest = 2;
|
||||||
@ -129,16 +129,8 @@ void test26b()
|
|||||||
|
|
||||||
/* Test what happens if we make LINK_MAX number of links. */
|
/* Test what happens if we make LINK_MAX number of links. */
|
||||||
System("touch foo");
|
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++) {
|
for (nlink = 2; nlink <= LINK_MAX; nlink++) {
|
||||||
bar[4] = (char) ((nlink / 10000) % 10) + '0';
|
sprintf(bar, "bar.%d", nlink);
|
||||||
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';
|
|
||||||
if (link("foo", bar) != 0) e(2);
|
if (link("foo", bar) != 0) e(2);
|
||||||
Stat(bar, &st);
|
Stat(bar, &st);
|
||||||
if (st.st_nlink != nlink) e(3);
|
if (st.st_nlink != nlink) e(3);
|
||||||
@ -150,11 +142,7 @@ if (LINK_MAX > 127) {
|
|||||||
Stat("foo", &st);
|
Stat("foo", &st);
|
||||||
if (st.st_nlink != LINK_MAX) e(5);
|
if (st.st_nlink != LINK_MAX) e(5);
|
||||||
for (nlink = 2; nlink <= LINK_MAX; nlink++) {
|
for (nlink = 2; nlink <= LINK_MAX; nlink++) {
|
||||||
bar[4] = (char) ((nlink / 10000) % 10) + '0';
|
sprintf(bar, "bar.%d", nlink);
|
||||||
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';
|
|
||||||
Stat(bar, &st2);
|
Stat(bar, &st2);
|
||||||
if (!stateq(&st, &st2)) e(6);
|
if (!stateq(&st, &st2)) e(6);
|
||||||
}
|
}
|
||||||
@ -167,16 +155,13 @@ if (LINK_MAX > 127) {
|
|||||||
|
|
||||||
/* Now unlink() the bar.### files */
|
/* Now unlink() the bar.### files */
|
||||||
for (nlink = LINK_MAX; nlink >= 2; nlink--) {
|
for (nlink = LINK_MAX; nlink >= 2; nlink--) {
|
||||||
bar[4] = (char) ((nlink / 100) % 10) + '0';
|
sprintf(bar, "bar.%d", nlink);
|
||||||
bar[5] = (char) ((nlink / 10) % 10) + '0';
|
|
||||||
bar[6] = (char) (nlink % 10) + '0';
|
|
||||||
Stat(bar, &st);
|
Stat(bar, &st);
|
||||||
if (st.st_nlink != nlink) e(10);
|
if (st.st_nlink != nlink) e(10);
|
||||||
Stat("foo", &st2);
|
Stat("foo", &st2);
|
||||||
if (!stateq(&st, &st2)) e(11);
|
if (!stateq(&st, &st2)) e(11);
|
||||||
if (unlink(bar) != 0) e(12);
|
if (unlink(bar) != 0) e(12);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Stat("foo", &st);
|
Stat("foo", &st);
|
||||||
if (st.st_nlink != 1) e(13); /* number of links back to 1 */
|
if (st.st_nlink != 1) e(13); /* number of links back to 1 */
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ void test28b()
|
|||||||
int other = 0, dot = 0, dotdot = 0; /* dirent counters */
|
int other = 0, dot = 0, dotdot = 0; /* dirent counters */
|
||||||
int rmdir_result; /* tmp var */
|
int rmdir_result; /* tmp var */
|
||||||
nlink_t nlink;
|
nlink_t nlink;
|
||||||
static char bar[] = "foo/bar.xxxxx";
|
static char bar[20];
|
||||||
int stat_loc;
|
int stat_loc;
|
||||||
|
|
||||||
subtest = 2;
|
subtest = 2;
|
||||||
@ -190,8 +190,6 @@ void test28b()
|
|||||||
if (rmdir("/.././/././/tmp/foo///////////////") != 0) e(6);
|
if (rmdir("/.././/././/tmp/foo///////////////") != 0) e(6);
|
||||||
if (rmdir("/tmp/foo") != -1) e(7); /* try again */
|
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. */
|
/* Test max path ed. */
|
||||||
if (mkdir(MaxName, 0777) != 0) e(9); /* make dir MaxName */
|
if (mkdir(MaxName, 0777) != 0) e(9); /* make dir MaxName */
|
||||||
if (rmdir(MaxName) != 0) e(10); /* and remove it */
|
if (rmdir(MaxName) != 0) e(10); /* and remove it */
|
||||||
@ -211,31 +209,21 @@ void test28b()
|
|||||||
if (errno != ENAMETOOLONG) e(22);
|
if (errno != ENAMETOOLONG) e(22);
|
||||||
|
|
||||||
/* Test what happens if the parent link count > LINK_MAX. */
|
/* Test what happens if the parent link count > LINK_MAX. */
|
||||||
if (mkdir("foo", 0777) != 0) e(23); /* make foo */
|
if (mkdir("foo", 0777) != 0) e(23);
|
||||||
if (LINK_MAX > 127) {
|
System("touch foo/xyzzy");
|
||||||
printf("[skip] "); /* takes to many resources */
|
for (nlink = 1; nlink < LINK_MAX; nlink++) { /* make all */
|
||||||
} else {
|
sprintf(bar, "foo/bar.%d", nlink);
|
||||||
for (nlink = 2; nlink < LINK_MAX; nlink++) { /* make all */
|
if (link("foo/xyzzy", bar) != 0) e(24);
|
||||||
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 (stat("foo/xyzzy", &st) != 0) e(25); /* foo now */
|
||||||
if (stat("foo", &st) != 0) e(25); /* foo now */
|
|
||||||
if (st.st_nlink != LINK_MAX) e(26); /* is full */
|
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. */
|
if (errno != EMLINK) e(28); /* entrys. */
|
||||||
System("rm -rf foo/nono"); /* Just in case. */
|
System("rm -rf foo/nono"); /* Just in case. */
|
||||||
|
|
||||||
/* Test if rmdir removes only empty dirs */
|
/* Test if rmdir removes only empty dirs */
|
||||||
if (rmdir("foo") != -1) e(29);/* not empty */
|
if (rmdir("foo") != -1) e(29);/* not empty */
|
||||||
if (errno != EEXIST && errno != ENOTEMPTY) e(30);
|
if (errno != EEXIST && errno != ENOTEMPTY) e(30);
|
||||||
}
|
|
||||||
/* Test if rmdir removes a dir with an empty file (it shouldn't.) */
|
/* Test if rmdir removes a dir with an empty file (it shouldn't.) */
|
||||||
System("rm -rf foo"); /* cleanup */
|
System("rm -rf foo"); /* cleanup */
|
||||||
if (mkdir("foo", 0777) != 0) e(31);
|
if (mkdir("foo", 0777) != 0) e(31);
|
||||||
@ -262,9 +250,12 @@ if (LINK_MAX > 127) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* See if ".." and "." are removed from the dir, and if it is
|
/* See if ".." and "." are removed from the dir, and if it is
|
||||||
* unwriteable * Note, we can not remove any files in the PARENT
|
* unwriteable
|
||||||
* process, because this * will make readdir unpredicatble. (see
|
* Note, we can not remove any files in the PARENT
|
||||||
* 1003.1 page 84 line 30.) However * removal of the directory is
|
* 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.
|
* not specified in the standard.
|
||||||
*/
|
*/
|
||||||
System("rm -rf /tmp/sema[12].07");
|
System("rm -rf /tmp/sema[12].07");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user