Unverified Commit 4f5a367a authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

add non-existing open test

parent dc0cf736
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -21,11 +21,21 @@ int main(int argc, char* argv[]) {
    string p = "/tmp/mountdir/file"s;
    char buffIn[] = "oops.";
    char *buffOut = new char[strlen(buffIn)];
    int fd;

    fd = open(p.c_str(), O_RDONLY);
    if(fd >= 0 ){
        cerr << "ERROR: Succeeded on opening non-existing file" << endl;
        return -1;
    }
    if(errno != ENOENT){
        cerr << "ERROR: wrong error number while opening non-existing file: " << errno << endl;
        return -1;
    }
    
    /* Write the file */

    auto fd = open(p.c_str(), O_WRONLY | O_CREAT, 0777);
    fd = open(p.c_str(), O_WRONLY | O_CREAT, 0777);
    if(fd < 0){
        cerr << "Error opening file (write)" << endl;
        return -1;