Ignore:
Timestamp:
Aug 30, 2008, 9:41:00 PM (13 years ago)
Author:
Peter
Message:

moving LFS test to separate file so skipping the test (when using --disable-largefile) becomes more visible.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/test/large_file_test.cc

    r1457 r1458  
    22
    33/*
    4   Copyright (C) 2006 Jari Häkkinen
    5   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    64  Copyright (C) 2008 Peter Johansson
    75
     
    3028#include "Suite.h"
    3129
    32 #include "yat/utility/FileUtil.h"
    33 #include "yat/utility/Exception.h"
    34 
    35 #include <fstream>
    36 #include <iostream>
    3730#include <string>
     31#include <sys/stat.h>
    3832
    3933using namespace theplu::yat;
     
    4337
    4438  test::Suite suite(argc, argv);
    45   suite.err() << "testing FileUtil ... " << std::endl;
    46 
    47   // checking permissions for current directory
    48   try {
    49     suite.err() << "FileUtil Test 1" << std::endl;
    50     bool testval=true;
    51     utility::FileUtil file(".");
    52     if (testval=file.exists())
    53       suite.err() << "\tfile exists: " << file.path() << std::endl;
    54     suite.add(testval);
    55     if (!(testval=file.permissions("rwx")))
    56       suite.err() << "\trwx permissions on " << file.path() << std::endl;
    57     suite.add(!testval);
    58     if (!(testval=file.permissions("rx")))
    59       suite.err() << "\trx permissions on " << file.path() << std::endl;
    60     suite.add(!testval);
    61     if (!(testval=file.permissions("d")))
    62       suite.err() << "\td permissions on " << file.path() << std::endl;
    63     suite.add(!testval);
    64   }
    65   catch (utility::IO_error e) {
    66     suite.add(false);
    67     suite.err() << e.what() << std::endl;
    68   }
    69 
    70   // checking permissions on non-existent file with ./ in path
    71   try {
    72     suite.err() << "FileUtil Test 2" << std::endl;
    73     bool testval=true;
    74     // filename below should be unique
    75     utility::FileUtil file("./fileio_test.sdf34DSF");
    76     suite.err() << "\tpath: " << std::endl;
    77     if (!(testval=file.exists()))
    78       suite.err() << "\tfile does not exist: " << file.path() << std::endl;
    79     suite.add(!testval);
    80     if (!(testval=file.permissions("r")))
    81       suite.err() << "\tr permission on " << file.path() << std::endl;
    82     suite.add(!testval);
    83     if (!(testval=file.permissions("rwx")))
    84       suite.err() << "\trwx permissions on " << file.path() << std::endl;
    85     suite.add(!testval);
    86     if (!(testval=file.permissions("w")))
    87       suite.err() << "\tw permission on " << file.path() << std::endl;
    88     suite.add(!testval); // 'w' on non-existent file ok if directory writeable
    89     if (!(testval=file.permissions("d")))
    90       suite.err() << "\td permission on " << file.path() << std::endl;
    91     suite.add(!testval);
    92   }
    93   catch (utility::IO_error e) {
    94     suite.add(false);
    95     suite.err() << e.what() << std::endl;
    96   }
    97 
    98   // checking permissions on non-existent file without ./ in path
    99   try {
    100     suite.err() << "FileUtil Test 3" << std::endl;
    101     bool testval=true;
    102     // filename below should be unique
    103     utility::FileUtil file("fileio_test.sdf34DSF");
    104     if (!(testval=file.exists()))
    105       suite.err() << "\tfile does not exist: " << file.path() << std::endl;
    106     suite.add(!testval);
    107     if (!(testval=file.permissions("r")))
    108       suite.err() << "\tr permission on " << file.path() << std::endl;
    109     suite.add(!testval);
    110     if (!(testval=file.permissions("rwx")))
    111       suite.err() << "\trwx permissions on " << file.path() << std::endl;
    112     suite.add(!testval);
    113     if (!(testval=file.permissions("w")))
    114       suite.err() << "\tw permission on " << file.path() << std::endl;
    115     suite.add(!testval); // 'w' on non-existent file ok if directory writeable
    116     if (!(testval=file.permissions("d")))
    117       suite.err() << "\td permission on " << file.path() << std::endl;
    118     suite.add(!testval);
    119   }
    120   catch (utility::IO_error e) {
    121     suite.add(false);
    122     suite.err() << e.what() << std::endl;
    123   }
    124 
    125   // checking permissions on non-existent file with non-existent
    126   // directories in path
    127   try {
    128     suite.err() << "FileUtil Test 4" << std::endl;
    129     bool testval=true;
    130      // intermediate dir must be unique!
    131     utility::FileUtil file("./fileio_test.sdf34DSF/file");
    132     if (!(testval=file.exists()))
    133       suite.err() << "\tfile does not exist: " << file.path() << std::endl;
    134     suite.add(!testval);
    135     if ((testval=file.permissions("r")))
    136       suite.err() << "\tr permission failed on " << file.path() << std::endl;
    137     suite.add(testval);
    138     if (testval=file.permissions("rwx"))
    139       suite.err() << "\trwx permissions failed on " << file.path() << std::endl;
    140     suite.add(testval);
    141     if (testval=file.permissions("w"))
    142       suite.err() << "\tw permission failed on " << file.path() << std::endl;
    143     suite.add(testval);
    144     if (testval=file.permissions("d"))
    145       suite.err() << "\td permission failed on " << file.path() << std::endl;
    146     suite.add(testval);
    147   }
    148   catch (utility::IO_error e) {
    149     suite.add(false);
    150     suite.err() << e.what() << std::endl;
    151   }
    152 
    153   // checking permissions on existent file after non-existence file
    154   // has been checked
    155   try {
    156     suite.err() << "FileUtil Test 5" << std::endl;
    157     bool testval=true;
    158      // intermediate dir must be unique!
    159     utility::FileUtil file("./fileio_test.sdf34DSF/file");
    160     if (!(testval=file.exists()))
    161       suite.err() << "\tfile does not exist: " << file.path() << std::endl;
    162     suite.add(!testval);
    163     utility::FileUtil file2(test::filename("fileutil_test.cc").c_str());
    164     if (!(testval=!file2.exists()))
    165       suite.err() << "\tfile does exist: " << file2.path() << std::endl;
    166     suite.add(!testval);
    167   }
    168   catch (utility::IO_error e) {
    169     suite.add(false);
    170     suite.err() << e.what() << std::endl;
    171   }
    172 
    173   try {
    174     suite.err() << "FileUtil Test 6" << std::endl;
    175     utility::FileUtil file("fileutil_test.cc");
    176     file.permissions("rxwa"); // should throw
    177     suite.add(false);
    178   }
    179   catch (std::invalid_argument& e) {
    180     suite.err() << "Expected exception thrown with what: " << e.what()
    181                 << std::endl;
    182   }
    18339
    18440  #ifndef YAT_LFS_DISABLED
     
    18642  #else
    18743  suite.err() << "Skipping test of large file support\n";
     44  exit(77);
    18845  #endif
    18946  return suite.return_value();
Note: See TracChangeset for help on using the changeset viewer.