Back to index

im-sdk  12.3.91
fop_test.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <fcntl.h>
00003 #include <unistd.h>
00004 #include <stdlib.h>
00005 #include <string.h>
00006 #include <sys/stat.h>
00007 #include <sys/types.h>
00008 #include <limits.h>
00009 #include <errno.h>
00010 #include <utime.h>
00011 
00012 #include "fop.h"
00013 
00014 extern void * nsfio_get_function(const char *);
00015 
00016 #define IML_NSC_TYPE_DESKTOP 1
00017 
00018 iml__nsc_create_t    nsfio__nsc_create;
00019 iml__nsc_free_t             nsfio__nsc_free;
00020 
00021 iml_nsc_open_t              nsfio_open;
00022 iml_nsc_read_t              nsfio_read;
00023 iml_nsc_readv_t             nsfio_readv;
00024 iml_nsc_write_t             nsfio_write;
00025 iml_nsc_writev_t     nsfio_writev;
00026 iml_nsc_close_t             nsfio_close;
00027 iml_nsc_creat_t             nsfio_creat;
00028 
00029 iml_nsc_lseek_t             nsfio_lseek;
00030 
00031 iml_nsc_stat_t              nsfio_stat;
00032 iml_nsc_lstat_t             nsfio_lstat;
00033 iml_nsc_fstat_t             nsfio_fstat;
00034 
00035 iml_nsc_mkdir_t             nsfio_mkdir;
00036 iml_nsc_rmdir_t             nsfio_rmdir;
00037 
00038 iml_nsc_symlink_t    nsfio_symlink;
00039 iml_nsc_readlink_t   nsfio_readlink;
00040 iml_nsc_link_t              nsfio_link;
00041 iml_nsc_unlink_t     nsfio_unlink;
00042 iml_nsc_rename_t     nsfio_rename;
00043 
00044 iml_nsc_fcntl_t             nsfio_fcntl;
00045 iml_nsc_truncate_t   nsfio_truncate;
00046 iml_nsc_ftruncate_t  nsfio_ftruncate;
00047 
00048 iml_nsc_opendir_t    nsfio_opendir;
00049 iml_nsc_readdir_t    nsfio_readdir;
00050 iml_nsc_closedir_t   nsfio_closedir;
00051 
00052 iml_nsc_access_t     nsfio_access;
00053 iml_nsc_chmod_t             nsfio_chmod;
00054 iml_nsc_fchmod_t     nsfio_fchmod;
00055 iml_nsc_chown_t             nsfio_chown;
00056 #if 0
00057 iml_nsc_lchown_t     nsfio_lchown;
00058 #endif /* 0 */
00059 iml_nsc_fchown_t     nsfio_fchown;
00060 iml_nsc_fpathconf_t  nsfio_fpathconf;
00061 iml_nsc_pathconf_t   nsfio_pathconf;
00062 iml_nsc_utime_t             nsfio_utime;
00063 iml_nsc_utimes_t     nsfio_utimes;
00064 
00065 #define BASEDIR      "/var/lib/iiim/le/test/dir"
00066 
00067 #define TEST_FILE1   "/var/lib/iiim/le/test/dir/test_file1"
00068 #define TEST_FILE2   "/var/lib/iiim/le/test/dir/test_file2"
00069 #define TEST_SYMLINK "test_file1"
00070 
00071 #define TEST_DIR_FILE1      "/var/lib/iiim/le/test/dir/test_dir1/fiiiileeee1"
00072 #define TEST_DIR_FILE2      "/var/lib/iiim/le/test/dir/test_dir1/f2"
00073 
00074 #define TEST_DIR1    "/var/lib/iiim/le/test/dir/test_dir1"
00075 #define ABC          "abcdefghijklmnopqrstuvwxyz"
00076 
00077 #if !defined(S_IAMB)
00078 #define S_IAMB       0x1FF
00079 #endif /* !S_IAMB */
00080 
00081 
00082 void
00083 test_prep(nsfio_t * nsc)
00084 {
00085     DIR *            dirp;
00086     struct dirent *  de;
00087     struct stat             st;
00088     char             path[PATH_MAX];
00089 
00090     umask(0);
00091 
00092     nsfio_mkdir(nsc, BASEDIR, 0777);
00093     dirp = nsfio_opendir(nsc, BASEDIR);
00094     while (NULL != (de = nsfio_readdir(nsc, dirp))) {
00095        if ((0 == strcmp(".", de->d_name)) ||
00096            (0 == strcmp("..", de->d_name))) {
00097            continue;
00098        }
00099        snprintf(path, sizeof (path), "%s/%s", BASEDIR, de->d_name);
00100        nsfio_stat(nsc, path, &st);
00101        if (0 == S_ISDIR(st.st_mode)) {
00102            nsfio_unlink(nsc, path);
00103        } else {
00104            nsfio_rmdir(nsc, path);
00105        }
00106    }
00107 }
00108 
00109 
00110 void
00111 test_open(nsfio_t * nsc)
00112 {
00113     int              fd;
00114     struct stat      st;
00115 
00116     printf("open: ");
00117     fd = nsfio_open(nsc, TEST_FILE1, O_RDWR);
00118     if (0 <= fd) {
00119        printf("fail: open should fail\n");
00120        nsfio_close(nsc, fd);
00121        return;
00122     }
00123 
00124     fd = nsfio_open(nsc, TEST_FILE1, O_RDWR | O_CREAT | O_TRUNC, 0612);
00125     if (fd < 0) {
00126        printf("fail: open should succeed\n");
00127        return;
00128     }
00129     nsfio_close(nsc, fd);
00130 
00131     if (nsfio_stat(nsc, TEST_FILE1, &st) < 0) {
00132        printf("fail: %s does not exist\n", TEST_FILE1);
00133        return;
00134     } else {
00135        if (0612 != (S_IAMB & st.st_mode)) {
00136            printf("fail: mode error: 0%3o\n", (S_IAMB & st.st_mode));
00137            return;
00138        }
00139     }
00140 
00141     fd = nsfio_open(nsc, TEST_FILE1, O_RDWR);
00142     if (fd < 0) {
00143        printf("fail: open should succeed (o_RDWR)\n");
00144        return;
00145     }
00146     nsfio_close(nsc, fd);
00147 
00148     printf("succeed\n");
00149 }
00150 
00151 
00152 void
00153 test_read(nsfio_t * nsc)
00154 {
00155     char      buf[1024];
00156     int              fd;
00157     int              rv;
00158 
00159     printf("read: ");
00160 
00161     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0777);
00162     nsfio_write(nsc, fd, "hogera", 7);
00163     nsfio_close(nsc, fd);
00164 
00165     memset(buf, 0, sizeof (buf));
00166     fd = nsfio_open(nsc, TEST_FILE1, O_RDONLY);
00167     rv = nsfio_read(nsc, fd, buf, sizeof (buf));
00168     nsfio_close(nsc, fd);
00169 
00170     if (7 != rv) {
00171        printf("fail - read length error\n");
00172        return;
00173     }
00174 
00175     if (0 != memcmp(buf, "hogera", 7)) {
00176        printf("fail - incorrect contents\n");
00177        return;
00178     }
00179 
00180     printf("succeed\n");
00181 }
00182 
00183 
00184 void
00185 test_readv(nsfio_t * nsc)
00186 {
00187     printf("readv: ");
00188     printf("succeed\n");
00189 }
00190 
00191 
00192 void
00193 test_write(nsfio_t * nsc)
00194 {
00195     char      buf[1024];
00196     int              fd;
00197     int              rv;
00198 
00199     printf("write: ");
00200 
00201     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0777);
00202 
00203     rv = nsfio_write(nsc, fd, "hogera", 7);
00204     nsfio_close(nsc, fd);
00205     if (7 != rv) {
00206        printf("fail - write length error\n");
00207        return;
00208     }
00209 
00210 
00211     memset(buf, 0, sizeof (buf));
00212     fd = nsfio_open(nsc, TEST_FILE1, O_RDONLY);
00213     rv = nsfio_read(nsc, fd, buf, sizeof (buf));
00214     nsfio_close(nsc, fd);
00215 
00216     if (0 != memcmp(buf, "hogera", 7)) {
00217        printf("fail - incorrect contents\n");
00218        return;
00219     }
00220 
00221      printf("succeed\n");
00222 }
00223 
00224 
00225 void
00226 test_writev(nsfio_t * nsc)
00227 {
00228     printf("writev: ");
00229     printf("succeed\n");
00230 }
00231 
00232 
00233 void
00234 test_close(nsfio_t * nsc)
00235 {
00236     int       fd;
00237     int       rv;
00238 
00239     printf("close: ");
00240 
00241     fd = nsfio_open(nsc, TEST_FILE1, O_RDWR | O_CREAT | O_TRUNC, 0777);
00242 
00243     rv = nsfio_close(nsc, fd);
00244     if (rv < 0) {
00245        printf("fail - close error");
00246        return;
00247     }
00248 
00249     fd = nsfio_open(nsc, TEST_FILE1, O_RDWR | O_CREAT | O_TRUNC, 0777);
00250 
00251     rv = nsfio_close(nsc, fd + 5);
00252     (void)nsfio_close(nsc, fd);
00253     if (0 <= rv) {
00254        printf("fail - close should fail");
00255        return;
00256     }
00257 
00258     printf("succeed\n");
00259 }
00260 
00261 
00262 void
00263 test_creat(nsfio_t * nsc)
00264 {
00265     int              fd;
00266     struct stat      st;
00267 
00268     printf("creat: ");
00269 
00270     if (0 == nsfio_stat(nsc, TEST_FILE1, &st)) {
00271        nsfio_unlink(nsc, TEST_FILE1);
00272        if (0 == nsfio_stat(nsc, TEST_FILE1, &st)) {
00273            printf("fail: can not remove %s\n", TEST_FILE1);
00274            return;
00275        }
00276     }
00277 
00278     fd = nsfio_creat(nsc, TEST_FILE1, 0700);
00279     if (fd < 0) {
00280        printf("fail: open should succeed\n");
00281        return;
00282     }
00283 
00284     if (nsfio_stat(nsc, TEST_FILE1, &st) < 0) {
00285        printf("fail: %s does not exist\n", TEST_FILE1);
00286        return;
00287     } else {
00288        if (0700 != (S_IAMB & st.st_mode)) {
00289            printf("fail: mode error: %04o\n", st.st_mode);
00290            return;
00291        }
00292     }
00293 
00294     nsfio_unlink(nsc, TEST_FILE1);
00295 
00296     printf("succeed\n");
00297 }
00298 
00299 
00300 void
00301 test_lseek(nsfio_t * nsc)
00302 {
00303     int              fd;
00304     char      buf[26];
00305 
00306     printf("lseek: ");
00307 
00308     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0666);
00309     nsfio_write(nsc, fd, ABC, 26);
00310     nsfio_close(nsc, fd);
00311 
00312     fd = nsfio_open(nsc, TEST_FILE1, O_RDONLY);
00313     nsfio_lseek(nsc, fd, 3, SEEK_SET);
00314     nsfio_read(nsc, fd, buf, 1);
00315     if ('d' != buf[0]) {
00316        printf("fail: SEEK_SET not working\n");
00317        return;
00318     }
00319     nsfio_lseek(nsc, fd, 3, SEEK_CUR);
00320     nsfio_read(nsc, fd, buf, 1);
00321     if ('h' != buf[0]) {
00322        printf("fail: SEEK_CUR not working\n");
00323        return;
00324     }
00325     nsfio_lseek(nsc, fd, -3, SEEK_END);
00326     nsfio_read(nsc, fd, buf, 1);
00327     if ('x' != buf[0]) {
00328        printf("fail: SEEK_END not working\n");
00329        return;
00330     }
00331 
00332     nsfio_close(nsc, fd);
00333     nsfio_unlink(nsc, TEST_FILE1);
00334 
00335     printf("succeed\n");
00336 }
00337 
00338 
00339 void
00340 test_stat(nsfio_t * nsc)
00341 {
00342     int              fd;
00343     struct stat      st;
00344 
00345     printf("stat: ");
00346 
00347     if (0 == nsfio_stat(nsc, TEST_FILE1, &st)) {
00348        printf("fail: stat should fail on none-existent file\n");
00349        return;
00350     }
00351 
00352     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00353     nsfio_write(nsc, fd, "data", 4);
00354     nsfio_close(nsc, fd);
00355 
00356     if (0 != nsfio_stat(nsc, TEST_FILE1, &st)) {
00357        printf("fail: stat should succeed\n");
00358        return;
00359     }
00360 
00361     if ((0655 != (S_IAMB & st.st_mode)) || (geteuid() != st.st_uid) || (4 != st.st_size)) {
00362        printf("fail: (0655 != %d) || (geteuid() != %d) || (4 != %lu))\n",
00363               st.st_mode, st.st_uid, (unsigned long)st.st_size);
00364        return;
00365     }
00366     
00367     nsfio_unlink(nsc, TEST_FILE1);
00368     printf("succeed\n");
00369 }
00370 
00371 
00372 void
00373 test_lstat(nsfio_t * nsc)
00374 {
00375     int              fd;
00376     struct stat      st;
00377 
00378     printf("lstat: ");
00379 
00380     if (0 == nsfio_lstat(nsc, TEST_FILE1, &st)) {
00381        printf("fail: lstat should fail on none-existent file\n");
00382        return;
00383     }
00384 
00385     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00386     nsfio_write(nsc, fd, "data", 4);
00387     nsfio_close(nsc, fd);
00388 
00389     if (0 != nsfio_lstat(nsc, TEST_FILE1, &st)) {
00390        printf("fail: lstat should succeed\n");
00391        return;
00392     }
00393 
00394     if ((0655 != (S_IAMB & st.st_mode)) ||
00395        (geteuid() != st.st_uid) ||
00396        (4 != st.st_size)) {
00397        printf("fail: (0655 != %d) || (geteuid() != %d) || (4 != %lu))\n",
00398               (S_IAMB & st.st_mode), st.st_uid, (unsigned long)st.st_size);
00399        return;
00400     }
00401     
00402     nsfio_unlink(nsc, TEST_FILE1);
00403     printf("succeed\n");
00404 }
00405 
00406 
00407 void
00408 test_fstat(nsfio_t * nsc)
00409 {
00410     int              fd;
00411     struct stat      st;
00412     int              rv;
00413 
00414     printf("fstat: ");
00415 
00416     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00417     nsfio_write(nsc, fd, "data", 4);
00418 
00419     rv = nsfio_fstat(nsc, fd, &st);
00420     nsfio_close(nsc, fd);
00421     nsfio_unlink(nsc, TEST_FILE1);
00422 
00423     if (0 != rv) {
00424        printf("fail: fstat should succeed\n");
00425        return;
00426     }
00427 
00428     if ((0655 != (S_IAMB & st.st_mode)) ||
00429        (geteuid() != st.st_uid) ||
00430        (4 != st.st_size)) {
00431        printf("fail: (0655 != %d) || (geteuid() != %d) || (4 != %lu))\n",
00432               (S_IAMB & st.st_mode), st.st_uid, (unsigned long)st.st_size);
00433        return;
00434     }
00435     
00436     printf("succeed\n");
00437 }
00438 
00439 
00440 void
00441 test_mkkdir(nsfio_t * nsc)
00442 {
00443     struct stat      st;
00444 
00445     printf("mkkdir: ");
00446 
00447     if (0 == nsfio_stat(nsc, TEST_DIR1, &st)) {
00448        nsfio_rmdir(nsc, TEST_DIR1);
00449     }
00450 
00451     nsfio_mkdir(nsc, TEST_DIR1, 0711);
00452     nsfio_stat(nsc, TEST_DIR1, &st);
00453     nsfio_rmdir(nsc, TEST_DIR1);
00454 
00455     if (0 == S_ISDIR(st.st_mode)) {
00456        printf("fail: not a directory\n");
00457        return;
00458     } else if (0711 != (S_IAMB & st.st_mode)) {
00459        printf("fail: incorrect permission: %04o\n", (S_IAMB & st.st_mode));
00460        return;
00461     } else if (getuid() != st.st_uid) {
00462        printf("fail: incorrect uid: %d\n", st.st_uid);
00463        return;
00464     }
00465 
00466     printf("succeed\n");
00467 }
00468 
00469 
00470 void
00471 test_rmdir(nsfio_t * nsc)
00472 {
00473     int              rv;
00474     struct stat      st;
00475 
00476     printf("rmdir: ");
00477 
00478     rv = nsfio_rmdir(nsc, TEST_DIR1);
00479     if (0 == rv) {
00480        printf("fail: rmdir should fail on non-existent directory\n");
00481        return;
00482     } else if (ENOENT != errno) {
00483        printf("fail: errno should be ENOENT\n");
00484        return;
00485     }
00486 
00487     nsfio_mkdir(nsc, TEST_DIR1, 0711);
00488     rv = nsfio_rmdir(nsc, TEST_DIR1);
00489     if (rv < 0) {
00490        printf("fail: errno should succeed\n");
00491        return;
00492     }
00493     if (0 == nsfio_stat(nsc, TEST_DIR1, &st)) {
00494        printf("fail: %s exists\n", TEST_DIR1);
00495        return;
00496     }
00497 
00498     printf("succeed\n");
00499 }
00500 
00501 
00502 void
00503 test_symlink(nsfio_t * nsc)
00504 {
00505     int              fd;
00506     struct stat      st;
00507 
00508     printf("symlink: ");
00509 
00510     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00511     nsfio_close(nsc, fd);
00512 
00513     if (0 != nsfio_symlink(nsc, TEST_SYMLINK, TEST_FILE2)) {
00514        printf("fail: symlink failed\n");
00515        nsfio_unlink(nsc, TEST_FILE1);
00516        return;
00517     }
00518 
00519     if (0 != nsfio_stat(nsc, TEST_FILE2, &st)) {
00520        printf("fail: stat on %s\n", TEST_FILE2);
00521     } else if (0 != nsfio_lstat(nsc, TEST_FILE2, &st)) {
00522        printf("fail: lstat on %s\n", TEST_FILE2);
00523     } else if (0 == S_ISLNK(st.st_mode)) {
00524        printf("fail: %s is not a symbolic link\n", TEST_FILE2);
00525     } else {
00526        printf("succeed\n");
00527     }
00528 
00529     nsfio_unlink(nsc, TEST_FILE1);
00530     nsfio_unlink(nsc, TEST_FILE2);
00531 }
00532 
00533 
00534 void
00535 test_readink(nsfio_t * nsc)
00536 {
00537     int              rv;
00538     char      buf[1024];
00539 
00540     printf("readlink: ");
00541 
00542     if (0 != nsfio_symlink(nsc, "symbolic link", TEST_FILE1)) {
00543        printf("fail: symlink failed\n");
00544        return;
00545     }
00546 
00547     rv = nsfio_readlink(nsc, TEST_FILE1, buf, sizeof (buf));
00548     nsfio_unlink(nsc, TEST_FILE1);
00549 
00550     if (0 < rv) {
00551        printf("fail: readlink failed\n");
00552     } else if (0 != strcmp("symlink link", buf)) {
00553        printf("fail: contents error \"%s\" != \"%s\"\n", "symlink link", buf);
00554     }
00555 
00556     return;
00557 }
00558 
00559 
00560 void
00561 test_link(nsfio_t * nsc)
00562 {
00563     int              fd;
00564     int              rv;
00565     struct stat      st;
00566 
00567     printf("link: ");
00568 
00569     rv = nsfio_link(nsc, TEST_FILE1, TEST_FILE2);
00570     if (0 == rv) {
00571        printf("error: link should fail\n");
00572        return;
00573     }
00574 
00575     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00576     nsfio_close(nsc, fd);
00577 
00578     rv = nsfio_link(nsc, TEST_FILE1, TEST_FILE2);
00579     if (0 != rv) {
00580        printf("error: link should succeed\n");
00581        return;
00582     }
00583 
00584     nsfio_unlink(nsc, TEST_FILE1);
00585 
00586     if (0 != nsfio_stat(nsc, TEST_FILE2, &st)) {
00587        printf("fail: stat on %s\n", TEST_FILE2);
00588     } else {
00589        printf("succeed\n");
00590     }
00591 
00592     nsfio_unlink(nsc, TEST_FILE2);
00593 }
00594 
00595 
00596 void
00597 test_unlink(nsfio_t * nsc)
00598 {
00599     int              fd;
00600     int              rv;
00601 
00602     printf("unlink: ");
00603 
00604     rv = nsfio_unlink(nsc, TEST_FILE1);
00605     if (0 == rv) {
00606        printf("error: unlink should fail\n");
00607        return;
00608     } else if (ENOENT != errno) {
00609        printf("error: errno should be ENOENT\n");
00610     }
00611 
00612     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00613     nsfio_close(nsc, fd);
00614 
00615     rv = nsfio_unlink(nsc, TEST_FILE1);
00616     if (0 != rv) {
00617        printf("error: unlink should succeed\n");
00618        return;
00619     }
00620 
00621     printf("succeed\n");
00622 }
00623 
00624 
00625 void
00626 test_rename(nsfio_t * nsc)
00627 {
00628     int              fd;
00629     int              rv;
00630     struct stat      st;
00631 
00632     printf("rename: ");
00633 
00634     rv = nsfio_rename(nsc, TEST_FILE1, TEST_FILE2);
00635     if (0 == rv) {
00636        printf("error: rename should fail\n");
00637        return;
00638     }
00639 
00640     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00641     nsfio_close(nsc, fd);
00642 
00643     rv = nsfio_rename(nsc, TEST_FILE1, TEST_FILE2);
00644     if (0 != rv) {
00645        printf("error: rename should succeed\n");
00646        return;
00647     }
00648 
00649     if (0 == nsfio_stat(nsc, TEST_FILE1, &st)) {
00650        printf("fail: stat on \"%s\" should fail\n", TEST_FILE1);
00651     } else if (0 != nsfio_stat(nsc, TEST_FILE2, &st)) {
00652        printf("fail: stat on \"%s\" should succeed\n", TEST_FILE2);
00653     } else {
00654        printf("succeed\n");
00655     }
00656 
00657     nsfio_unlink(nsc, TEST_FILE1);
00658     nsfio_unlink(nsc, TEST_FILE2);
00659 }
00660 
00661 
00662 void
00663 test_fcntl(nsfio_t * nsc)
00664 {
00665     int              fd;
00666     int              rv;
00667 
00668     printf("fcntl: ");
00669 
00670     rv = nsfio_fcntl(nsc, 99, F_GETFD);
00671     if (0 <= rv) {
00672        printf("error: fcntl on invalid fd should fail\n");
00673        return;
00674     }
00675 
00676     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00677 
00678     nsfio_fcntl(nsc, fd, F_SETFD, FD_CLOEXEC);
00679     rv = nsfio_fcntl(nsc, fd, F_GETFD);
00680     if (rv < 0) {
00681        printf("error: fcntl should succeed\n");
00682     } else if (FD_CLOEXEC != rv) {
00683        printf("error: invalid flags 0x%x\n", rv);
00684     } else {
00685        printf("succeed\n");
00686     }
00687 
00688     nsfio_close(nsc, fd);
00689     nsfio_unlink(nsc, TEST_FILE1);
00690 }
00691 
00692 
00693 void
00694 test_truncate(nsfio_t * nsc)
00695 {
00696     int              fd;
00697     struct stat      st;
00698     int              rv;
00699 
00700     printf("truncate: ");
00701 
00702     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00703 
00704     nsfio_write(nsc, fd, ABC, 26);
00705     nsfio_close(nsc, fd);
00706 
00707     rv = nsfio_truncate(nsc, TEST_FILE1, 16);
00708     if (0 != rv) {
00709        printf("fail: truncate should succeed\n");
00710     } else if (0 != nsfio_stat(nsc, TEST_FILE1, &st)) {
00711        printf("fail: stat error on %s\n", TEST_FILE1);
00712        if (16 != st.st_size) {
00713            printf("fail: size not turncated %lu\n", (unsigned long)st.st_size);
00714        } else {
00715            printf("succeed\n");
00716        }
00717     } else {
00718        printf("succeed\n");
00719     }
00720 
00721     nsfio_unlink(nsc, TEST_FILE1);
00722 }
00723 
00724 
00725 void
00726 test_ftruncate(nsfio_t * nsc)
00727 {
00728     int              fd;
00729     struct stat      st;
00730     int              rv;
00731 
00732     printf("ftruncate: ");
00733 
00734     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00735 
00736     nsfio_write(nsc, fd, ABC, 26);
00737 
00738     rv = nsfio_ftruncate(nsc, fd, 16);
00739     nsfio_close(nsc, fd);
00740 
00741     if (0 != rv) {
00742        printf("fail: truncate should succeed\n");
00743     } else if (0 != nsfio_stat(nsc, TEST_FILE1, &st)) {
00744        printf("fail: stat error on %s\n", TEST_FILE1);
00745        if (16 != st.st_size) {
00746            printf("fail: size not truncated %lu\n", (unsigned long)st.st_size);
00747        } else {
00748            printf("succeed\n");
00749        }
00750     } else {
00751        printf("succeed\n");
00752     }
00753 
00754     nsfio_unlink(nsc, TEST_FILE1);
00755 }
00756 
00757 
00758 void
00759 test_opendir(nsfio_t * nsc)
00760 {
00761     int                     fd;
00762     DIR *            dirp;
00763     struct dirent *  de;
00764     char             path[PATH_MAX];
00765     int                     found1;
00766     int                     found2;
00767 
00768     printf("opendir: ");
00769 
00770     nsfio_mkdir(nsc, TEST_DIR1, 0777);
00771     fd = nsfio_open(nsc, TEST_DIR_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00772     nsfio_close(nsc, fd);
00773     fd = nsfio_open(nsc, TEST_DIR_FILE2, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00774     nsfio_close(nsc, fd);
00775     found1 = 0;
00776     found2 = 0;
00777 
00778     dirp = nsfio_opendir(nsc, TEST_DIR1);
00779     while (NULL != (de = nsfio_readdir(nsc, dirp))) {
00780        if ((0 == strcmp(".", de->d_name)) ||
00781            (0 == strcmp("..", de->d_name))) {
00782            continue;
00783        }
00784        snprintf(path, sizeof (path), "%s/%s", TEST_DIR1, de->d_name);
00785        if (0 == strcmp(path, TEST_DIR_FILE1)) {
00786            found1 = 1;
00787        } else if (0 == strcmp(path, TEST_DIR_FILE2)) {
00788            found2 = 1;
00789        }
00790     }
00791     nsfio_closedir(nsc, dirp);
00792 
00793     if ((1 == found1) && (1 == found2)) {
00794        printf("succeed\n");
00795     } else {
00796        printf("fail: file not found\n");
00797     }
00798 
00799     nsfio_unlink(nsc, TEST_DIR_FILE1);
00800     nsfio_unlink(nsc, TEST_DIR_FILE2);
00801     nsfio_rmdir(nsc, TEST_DIR1);
00802 }
00803 
00804 
00805 void
00806 test_readdir(nsfio_t * nsc)
00807 {
00808     int                     fd;
00809     DIR *            dirp;
00810     struct dirent *  de;
00811     char             path[PATH_MAX];
00812     int                     found1;
00813     int                     found2;
00814 
00815     printf("readdir: ");
00816 
00817     nsfio_mkdir(nsc, TEST_DIR1, 0777);
00818     fd = nsfio_open(nsc, TEST_DIR_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00819     nsfio_close(nsc, fd);
00820     fd = nsfio_open(nsc, TEST_DIR_FILE2, O_WRONLY | O_CREAT | O_TRUNC, 0655);
00821     nsfio_close(nsc, fd);
00822     found1 = 0;
00823     found2 = 0;
00824 
00825     dirp = nsfio_opendir(nsc, TEST_DIR1);
00826     while (NULL != (de = nsfio_readdir(nsc, dirp))) {
00827        if ((0 == strcmp(".", de->d_name)) ||
00828            (0 == strcmp("..", de->d_name))) {
00829            continue;
00830        }
00831        snprintf(path, sizeof (path), "%s/%s", TEST_DIR1, de->d_name);
00832        if (0 == strcmp(path, TEST_DIR_FILE1)) {
00833            found1 = 1;
00834        } else if (0 == strcmp(path, TEST_DIR_FILE2)) {
00835            found2 = 1;
00836        }
00837     }
00838     nsfio_closedir(nsc, dirp);
00839 
00840     if ((1 == found1) && (1 == found2)) {
00841        printf("succeed\n");
00842     } else {
00843        printf("fail: files not found\n");
00844     }
00845 
00846     nsfio_unlink(nsc, TEST_DIR_FILE1);
00847     nsfio_unlink(nsc, TEST_DIR_FILE2);
00848     nsfio_rmdir(nsc, TEST_DIR1);
00849 }
00850 
00851 
00852 void
00853 test_closedir(nsfio_t * nsc)
00854 {
00855     DIR *            dirp;
00856 
00857     printf("closedir: ");
00858 
00859     nsfio_mkdir(nsc, TEST_DIR1, 0777);
00860 
00861     dirp = nsfio_opendir(nsc, TEST_DIR1);
00862     if (0 == nsfio_closedir(nsc, dirp)) {
00863        printf("succeed\n");
00864     } else {
00865        printf("failed\n");
00866     }
00867 
00868     nsfio_rmdir(nsc, TEST_DIR1);
00869 }
00870 
00871 
00872 void
00873 test_access(nsfio_t * nsc)
00874 {
00875     int       rv;
00876     int       fd;
00877 
00878     printf("access: ");
00879 
00880     rv = nsfio_access(nsc, TEST_FILE1, F_OK);
00881     if (0 == rv) {
00882        printf("fail: F_OK should fail on none-existent file\n");
00883        return;
00884     }
00885 
00886     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0600);
00887     nsfio_close(nsc, fd);
00888 
00889     if (0 != nsfio_access(nsc, TEST_FILE1, R_OK)) {
00890        printf("fail: R_OK should succeed\n");
00891     } else if (0 == nsfio_access(nsc, TEST_FILE1, X_OK)) {
00892        printf("fail: X_OK should fail\n");
00893     } else {
00894        printf("succeed\n");
00895     }
00896 
00897     nsfio_unlink(nsc, TEST_FILE1);
00898 }
00899 
00900 
00901 void
00902 test_chmod(nsfio_t * nsc)
00903 {
00904     int              rv;
00905     int              fd;
00906     struct stat      st;
00907 
00908     printf("chmod: ");
00909 
00910     rv = nsfio_chmod(nsc, TEST_FILE1, 0555);
00911     if (0 == rv) {
00912        printf("fail: should fail on none-existent file\n");
00913        return;
00914     }
00915 
00916     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0600);
00917     nsfio_close(nsc, fd);
00918 
00919     if (0 != nsfio_chmod(nsc, TEST_FILE1, 0555)) {
00920        printf("fail: should succeed\n");
00921     } else {
00922        nsfio_stat(nsc, TEST_FILE1, &st);
00923        if (0555 != (S_IAMB & st.st_mode)) {
00924            printf("fail: incorrect mode: %d\n", (S_IAMB & st.st_mode));
00925        } else {
00926            printf("succeed\n");
00927        }
00928     }
00929 
00930     nsfio_unlink(nsc, TEST_FILE1);
00931 }
00932 
00933 
00934 void
00935 test_fchmod(nsfio_t * nsc)
00936 {
00937     int              rv;
00938     int              fd;
00939     struct stat      st;
00940 
00941     printf("fchmod: ");
00942 
00943     rv = nsfio_fchmod(nsc, 99, 0555);
00944     if (0 == rv) {
00945        printf("fail: should fail on none-existent file\n");
00946        return;
00947     }
00948 
00949     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0600);
00950 
00951     if (0 != nsfio_fchmod(nsc, fd, 0555)) {
00952        printf("fail: should succeed\n");
00953     } else {
00954        nsfio_fstat(nsc, fd, &st);
00955        if (0555 != (S_IAMB & st.st_mode)) {
00956            printf("fail: incorrect mode: %d\n", (S_IAMB & st.st_mode));
00957        } else {
00958            printf("succeed\n");
00959        }
00960     }
00961 
00962     nsfio_close(nsc, fd);
00963     nsfio_unlink(nsc, TEST_FILE1);
00964 }
00965 
00966 
00967 void
00968 test_chown(nsfio_t * nsc)
00969 {
00970     int              rv;
00971     int              fd;
00972     int              errno_save;
00973 
00974     printf("chown: ");
00975 
00976     rv = nsfio_chown(nsc, TEST_FILE1, 99, 99);
00977     if (0 == rv) {
00978        printf("fail: should fail on non-existent file\n");
00979        return;
00980     } else if (ENOENT != errno) {
00981        printf("fail: invalid errno: %d should be ENOENT (%d)\n",
00982               errno, ENOENT);
00983        return;
00984     }
00985 
00986     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0600);
00987     nsfio_close(nsc, fd);
00988 
00989     rv = nsfio_chown(nsc, TEST_FILE1, 99, 99);
00990     errno_save = errno;
00991 
00992     switch (geteuid()) {
00993     case 0:
00994        if (0 != rv) {
00995            printf("fail: uid = %d: should succeed\n", geteuid());
00996        } else {
00997            printf("succeed\n");
00998        }
00999        break;
01000     default:
01001        if (0 == rv) {
01002            printf("fail: uid = %d: should fail\n", geteuid());
01003        } else if (EPERM != errno_save) {
01004            printf("invalid errno: %d should be EPERM (%d)\n", 
01005                  errno_save, EPERM);
01006        } else {
01007            printf("succeed\n");
01008        }
01009        break;
01010     }
01011 
01012     nsfio_unlink(nsc, TEST_FILE1);
01013 }
01014 
01015 
01016 #if 0
01017 void
01018 test_lchown(nsfio_t * nsc)
01019 {
01020     int              rv;
01021     int              fd;
01022     int              errno_save;
01023     uid_t     uid;
01024 
01025     printf("lchown: ");
01026 
01027     uid = geteuid();
01028 
01029     rv = nsfio_lchown(nsc, TEST_FILE1, 99, 99);
01030     if (0 == rv) {
01031        printf("fail: should fail on non-existent file\n");
01032        return;
01033     } else if ((0 == uid) && (ENOENT != errno)) {
01034        printf("fail: invalid errno: %d should be ENOENT (%d)\n",
01035               errno, ENOENT);
01036        return;
01037     } else if ((0 != uid) && (EPERM != errno)) {
01038        printf("fail: invalid errno: %d should be EPERM (%d)\n",
01039               errno, EPERM);
01040        return;
01041     }
01042 
01043     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0600);
01044     nsfio_close(nsc, fd);
01045 
01046     rv = nsfio_lchown(nsc, TEST_FILE1, 99, 99);
01047     errno_save = errno;
01048 
01049     switch (geteuid()) {
01050     case 0:
01051        if (0 != rv) {
01052            printf("fail: uid = %d: should succeed\n", geteuid());
01053        } else {
01054            printf("succeed\n");
01055        }
01056        break;
01057     default:
01058        if (0 == rv) {
01059            printf("fail: uid = %d: should fail\n", geteuid());
01060        } else if (EPERM != errno_save) {
01061            printf("invalid errno: %d should be EPERM (%d)\n", 
01062                  errno_save, EPERM);
01063        } else {
01064            printf("succeed\n");
01065        }
01066        break;
01067     }
01068 
01069     nsfio_unlink(nsc, TEST_FILE1);
01070 }
01071 #endif /* 0 */
01072 
01073 
01074 void
01075 test_fchown(nsfio_t * nsc)
01076 {
01077     int              rv;
01078     int              fd;
01079     int              errno_save;
01080     uid_t     uid;
01081 
01082     printf("fchown: ");
01083 
01084     uid = geteuid();
01085 
01086     rv = nsfio_fchown(nsc, 99, 99, 99);
01087     if (0 == rv) {
01088        printf("fail: should fail on non-existent file\n");
01089        return;
01090     } else if (EBADF != errno) {
01091        printf("fail: invalid errno: %d should be EBADF (%d)\n", errno, EBADF);
01092        return;
01093     }
01094 
01095     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0600);
01096 
01097     rv = nsfio_fchown(nsc, fd, 99, 99);
01098     errno_save = errno;
01099 
01100     switch (geteuid()) {
01101     case 0:
01102        if (0 != rv) {
01103            printf("fail: uid = %d: should succeed\n", geteuid());
01104        } else {
01105            printf("succeed\n");
01106        }
01107        break;
01108     default:
01109        if (0 == rv) {
01110            printf("fail: uid = %d: should fail\n", geteuid());
01111        } else if (EPERM != errno_save) {
01112            printf("invalid errno: %d should be EPERM (%d)\n", 
01113                  errno_save, EPERM);
01114        } else {
01115            printf("succeed\n");
01116        }
01117        break;
01118     }
01119 
01120     nsfio_close(nsc, fd);
01121     nsfio_unlink(nsc, TEST_FILE1);
01122 }
01123 
01124 
01125 void
01126 test_fpathconf(nsfio_t * nsc)
01127 {
01128     long      rv;
01129     int              fd;
01130 
01131     printf("fpathconf: ");
01132 
01133     rv = nsfio_fpathconf(nsc, 99, _PC_PATH_MAX);
01134     if (-1 != rv) {
01135        printf("fail: should fail\n");
01136        return;
01137     } else if (EBADF != errno) {
01138        printf("fail: invalid errno: %d should be EBADF (%d)\n",
01139               errno, EBADF);
01140        return;
01141     }
01142 
01143     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0600);
01144 
01145     rv = nsfio_fpathconf(nsc, fd, _PC_PATH_MAX);
01146     if (-1 != rv) {
01147        printf("succeed\n");
01148     } else {
01149        printf("fail: %ld\n", rv);
01150     }
01151 
01152     nsfio_close(nsc, fd);
01153     nsfio_unlink(nsc, TEST_FILE1);
01154 }
01155 
01156 
01157 void
01158 test_pathconf(nsfio_t * nsc)
01159 {
01160     long      rv;
01161     int              fd;
01162 
01163     printf("pathconf: ");
01164 
01165     rv = nsfio_pathconf(nsc, TEST_FILE1, _PC_PATH_MAX);
01166     if (-1 != rv) {
01167        printf("fail: should fail\n");
01168        return;
01169     } else if (ENOENT != errno) {
01170        printf("fail: invalid errno: %d should be ENOENT (%d)\n",
01171               errno, ENOENT);
01172        return;
01173     }
01174 
01175     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0600);
01176     nsfio_close(nsc, fd);
01177 
01178     rv = nsfio_pathconf(nsc, TEST_FILE1, _PC_PATH_MAX);
01179     if (-1 != rv) {
01180        printf("succeed\n");
01181     } else {
01182        printf("fail: %lu\n", rv);
01183     }
01184 
01185     nsfio_unlink(nsc, TEST_FILE1);
01186 }
01187 
01188 
01189 void
01190 test_utime(nsfio_t * nsc)
01191 {
01192     int       rv;
01193     int       fd;
01194 
01195     printf("utime: ");
01196 
01197     rv = nsfio_utime(nsc, TEST_FILE1, NULL);
01198     if (-1 != rv) {
01199        printf("fail: should fail");
01200        return;
01201     } else if (ENOENT != errno) {
01202        printf("fail: invalid errno: %d should be ENOENT (%d)\n",
01203               errno, ENOENT);
01204        return;
01205     }
01206 
01207     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0600);
01208     nsfio_close(nsc, fd);
01209 
01210     rv = nsfio_utime(nsc, TEST_FILE1, NULL);
01211     if (-1 != rv) {
01212        printf("succeed\n");
01213     } else {
01214        printf("fail: %d\n", rv);
01215     }
01216 
01217     nsfio_unlink(nsc, TEST_FILE1);
01218 }
01219 
01220 
01221 void
01222 test_utimes(nsfio_t * nsc)
01223 {
01224     int       rv;
01225     int       fd;
01226 
01227     printf("utimes: ");
01228 
01229     rv = nsfio_utimes(nsc, TEST_FILE1, NULL);
01230     if (-1 != rv) {
01231        printf("fail: should fail");
01232        return;
01233     } else if (ENOENT != errno) {
01234        printf("fail: invalid errno: %d should be ENOENT (%d)\n",
01235               errno, ENOENT);
01236        return;
01237     }
01238 
01239     fd = nsfio_open(nsc, TEST_FILE1, O_WRONLY | O_CREAT | O_TRUNC, 0600);
01240     nsfio_close(nsc, fd);
01241 
01242     rv = nsfio_utimes(nsc, TEST_FILE1, NULL);
01243     if (-1 != rv) {
01244        printf("succeed\n");
01245     } else {
01246        printf("fail: %d\n", rv);
01247     }
01248 
01249     nsfio_unlink(nsc, TEST_FILE1);
01250 }
01251 
01252 
01253 int
01254 main()
01255 {
01256     nsfio_t *        nsc;
01257 
01258     nsfio__nsc_create =
01259        (iml__nsc_create_t)(nsfio_get_function("_nsc_create"));
01260     if (NULL == nsfio__nsc_create) fprintf(stderr, "_nsc_create: fail\n");
01261     nsfio__nsc_free = (iml__nsc_free_t)(nsfio_get_function("_nsc_free"));
01262     if (NULL == nsfio__nsc_free) fprintf(stderr, "_nsc_free: fail\n");
01263     nsfio_access = (iml_nsc_access_t)(nsfio_get_function("access"));
01264     if (NULL == nsfio_access) fprintf(stderr, "access: fail\n");
01265     nsfio_chmod = (iml_nsc_chmod_t)(nsfio_get_function("chmod"));
01266     if (NULL == nsfio_chmod) fprintf(stderr, "chmod: fail\n");
01267     nsfio_fchmod = (iml_nsc_fchmod_t)(nsfio_get_function("fchmod"));
01268     if (NULL == nsfio_fchmod) fprintf(stderr, "fchmod: fail\n");
01269     nsfio_chown = (iml_nsc_chown_t)(nsfio_get_function("chown"));
01270     if (NULL == nsfio_chown) fprintf(stderr, "chown: fail\n");
01271 #if 0
01272     nsfio_lchown = (iml_nsc_lchown_t)(nsfio_get_function("lchown"));
01273     if (NULL == nsfio_lchown) fprintf(stderr, "chown: lfail\n");
01274 #endif /* 0 */
01275     nsfio_fchown = (iml_nsc_fchown_t)(nsfio_get_function("fchown"));
01276     if (NULL == nsfio_fchown) fprintf(stderr, "fchown: fail\n");
01277     nsfio_close = (iml_nsc_close_t)(nsfio_get_function("close"));
01278     if (NULL == nsfio_close) fprintf(stderr, "close: fail\n");
01279     nsfio_closedir = (iml_nsc_closedir_t)(nsfio_get_function("closedir"));
01280     if (NULL == nsfio_closedir) fprintf(stderr, "closedir: fail\n");
01281     nsfio_creat = (iml_nsc_creat_t)(nsfio_get_function("creat"));
01282     if (NULL == nsfio_creat) fprintf(stderr, "creat: fail\n");
01283     nsfio_fcntl = (iml_nsc_fcntl_t)(nsfio_get_function("fcntl"));
01284     if (NULL == nsfio_fcntl) fprintf(stderr, "fcntl: fail\n");
01285     nsfio_fpathconf = (iml_nsc_fpathconf_t)(nsfio_get_function("fpathconf"));
01286     if (NULL == nsfio_fpathconf) fprintf(stderr, "fpathconf: fail\n");
01287     nsfio_fstat = (iml_nsc_fstat_t)(nsfio_get_function("fstat"));
01288     if (NULL == nsfio_fstat) fprintf(stderr, "fstat: fail\n");
01289     nsfio_ftruncate = (iml_nsc_ftruncate_t)(nsfio_get_function("ftruncate"));
01290     if (NULL == nsfio_ftruncate) fprintf(stderr, "ftruncate: fail\n");
01291     nsfio_link = (iml_nsc_link_t)(nsfio_get_function("link"));
01292     if (NULL == nsfio_link) fprintf(stderr, "link: fail\n");
01293     nsfio_lseek = (iml_nsc_lseek_t)(nsfio_get_function("lseek"));
01294     if (NULL == nsfio_lseek) fprintf(stderr, "lseek: fail\n");
01295     nsfio_lstat = (iml_nsc_lstat_t)(nsfio_get_function("lstat"));
01296     if (NULL == nsfio_lstat) fprintf(stderr, "lstat: fail\n");
01297     nsfio_mkdir = (iml_nsc_mkdir_t)(nsfio_get_function("mkdir"));
01298     if (NULL == nsfio_mkdir) fprintf(stderr, "mkdir: fail\n");
01299     nsfio_open = (iml_nsc_open_t)(nsfio_get_function("open"));
01300     if (NULL == nsfio_open) fprintf(stderr, "open: fail\n");
01301     nsfio_opendir = (iml_nsc_opendir_t)(nsfio_get_function("opendir"));
01302     if (NULL == nsfio_opendir) fprintf(stderr, "opendir: fail\n");
01303     nsfio_pathconf = (iml_nsc_pathconf_t)(nsfio_get_function("pathconf"));
01304     if (NULL == nsfio_pathconf) fprintf(stderr, "pathconf: fail\n");
01305     nsfio_read = (iml_nsc_read_t)(nsfio_get_function("read"));
01306     if (NULL == nsfio_read) fprintf(stderr, "read: fail\n");
01307     nsfio_readdir = (iml_nsc_readdir_t)(nsfio_get_function("readdir"));
01308     if (NULL == nsfio_readdir) fprintf(stderr, "readdir: fail\n");
01309     nsfio_readv = (iml_nsc_readv_t)(nsfio_get_function("readv"));
01310     if (NULL == nsfio_readv) fprintf(stderr, "readv: fail\n");
01311     nsfio_rename = (iml_nsc_rename_t)(nsfio_get_function("rename"));
01312     if (NULL == nsfio_rename) fprintf(stderr, "rename: fail\n");
01313     nsfio_rmdir = (iml_nsc_rmdir_t)(nsfio_get_function("rmdir"));
01314     if (NULL == nsfio_rmdir) fprintf(stderr, "rmdir: fail\n");
01315     nsfio_stat = (iml_nsc_stat_t)(nsfio_get_function("stat"));
01316     if (NULL == nsfio_stat) fprintf(stderr, "stat: fail\n");
01317     nsfio_symlink = (iml_nsc_symlink_t)(nsfio_get_function("symlink"));
01318     if (NULL == nsfio_symlink) fprintf(stderr, "symlink: fail\n");
01319     nsfio_truncate = (iml_nsc_truncate_t)(nsfio_get_function("truncate"));
01320     if (NULL == nsfio_truncate) fprintf(stderr, "truncate: fail\n");
01321     nsfio_unlink = (iml_nsc_unlink_t)(nsfio_get_function("unlink"));
01322     if (NULL == nsfio_unlink) fprintf(stderr, "unlink: fail\n");
01323     nsfio_utime = (iml_nsc_utime_t)(nsfio_get_function("utime"));
01324     if (NULL == nsfio_utime) fprintf(stderr, "utime: fail\n");
01325     nsfio_utimes = (iml_nsc_utimes_t)(nsfio_get_function("utimes"));
01326     if (NULL == nsfio_utimes) fprintf(stderr, "utimes: fail\n");
01327     nsfio_write = (iml_nsc_write_t)(nsfio_get_function("write"));
01328     if (NULL == nsfio_write) fprintf(stderr, "write: fail\n");
01329     nsfio_writev = (iml_nsc_writev_t)(nsfio_get_function("writev"));
01330     if (NULL == nsfio_writev) fprintf(stderr, "writev: fail\n");
01331 
01332     nsc = nsfio__nsc_create("test", IML_NSC_TYPE_DESKTOP, NULL);
01333 
01334     test_prep(nsc);
01335     test_open(nsc);
01336     test_read(nsc);
01337     test_readv(nsc);
01338     test_write(nsc);
01339     test_writev(nsc);
01340     test_close(nsc);
01341     test_creat(nsc);
01342     test_lseek(nsc);
01343     test_stat(nsc);
01344     test_lstat(nsc);
01345     test_fstat(nsc);
01346     test_mkkdir(nsc);
01347     test_rmdir(nsc);
01348     test_symlink(nsc);
01349     test_link(nsc);
01350     test_unlink(nsc);
01351     test_rename(nsc);
01352     test_fcntl(nsc);
01353     test_truncate(nsc);
01354     test_ftruncate(nsc);
01355     test_opendir(nsc);
01356     test_readdir(nsc);
01357     test_closedir(nsc);
01358     test_access(nsc);
01359     test_chmod(nsc);
01360     test_fchmod(nsc);
01361     test_chown(nsc);
01362 #if 0
01363     test_lchown(nsc);
01364 #endif /* 0 */
01365     test_fchown(nsc);
01366     test_fpathconf(nsc);
01367     test_pathconf(nsc);
01368     test_utime(nsc);
01369     test_utimes(nsc);
01370 
01371     nsfio__nsc_free(nsc);
01372 
01373     return 0;
01374 }
01375 
01376 
01377 /* Local Variables: */
01378 /* c-file-style: "iiim-project" */
01379 /* End: */