autodriver/autodriver.c
static void dump_output(void) {
    int outfd;
    if ((outfd = open(OUTPUT_FILE, O_RDONLY)) < 0) {
        ERROR_ERRNO("Opening output file at the end of test");
        exit(EXIT_OSERROR);
    }

    struct stat stat;
    if (fstat(outfd, &stat) < 0) {
        ERROR_ERRNO("Statting output file");
        exit(EXIT_OSERROR);
    }
    outputFileSize = stat.st_size;

    if (args.osize > 0 && stat.st_size > args.osize) {
        MESSAGE("Output size %lu > limit %u -- will elide in the middle",
                stat.st_size, args.osize);
        // Streaming feedback: just print out the end of the output file.
        // We've already printed the rest to stdout.
        if (args.stream) {
            unsigned end_size = min(1000, outputFileSize - args.osize); // 1 KB
            if (dump_file(outfd, end_size, stat.st_size - end_size) < 0) {
                ERROR("dump file for streaming feedback failed");
                exit(EXIT_OSERROR);
            }
        // Otherwise, ellide the middle half.
        } else {
            unsigned part_size = args.osize / 2;
            if (dump_file(outfd, part_size, 0) < 0) {
                exit(EXIT_OSERROR);
            }
            if (dump_file(outfd, part_size, stat.st_size - part_size) < 0) {
                exit(EXIT_OSERROR);
            }
        }
    } else if (!args.stream) {
        if (dump_file(outfd, stat.st_size, 0) < 0) {
            exit(EXIT_OSERROR);
        }
    }
    if (close(outfd) < 0) {
        ERROR_ERRNO("Closing output file at the end of test");
        exit(EXIT_OSERROR);
    }
}
/**
 * @brief Dumps the output of the job, truncating if necessary
 */
@brief Dumps the output of the job, truncating if necessary
@brief Dumps the output of the job truncating if necessary
static void dump_output(void) {
    int outfd;
    if ((outfd = open(OUTPUT_FILE, O_RDONLY)) < 0) {
        ERROR_ERRNO("Opening output file at the end of test");
        exit(EXIT_OSERROR);
    }
    struct stat stat;
    if (fstat(outfd, &stat) < 0) {
        ERROR_ERRNO("Statting output file");
        exit(EXIT_OSERROR);
    }
    outputFileSize = stat.st_size;
    if (args.osize > 0 && stat.st_size > args.osize) {
        MESSAGE("Output size %lu > limit %u -- will elide in the middle",
                stat.st_size, args.osize);
        if (args.stream) {
            unsigned end_size = min(1000, outputFileSize - args.osize); 
            if (dump_file(outfd, end_size, stat.st_size - end_size) < 0) {
                ERROR("dump file for streaming feedback failed");
                exit(EXIT_OSERROR);
            }
        } else {
            unsigned part_size = args.osize / 2;
            if (dump_file(outfd, part_size, 0) < 0) {
                exit(EXIT_OSERROR);
            }
            if (dump_file(outfd, part_size, stat.st_size - part_size) < 0) {
                exit(EXIT_OSERROR);
            }
        }
    } else if (!args.stream) {
        if (dump_file(outfd, stat.st_size, 0) < 0) {
            exit(EXIT_OSERROR);
        }
    }
    if (close(outfd) < 0) {
        ERROR_ERRNO("Closing output file at the end of test");
        exit(EXIT_OSERROR);
    }
}
static void dump_output ( void ) { int outfd ; if ( ( outfd = open ( OUTPUT_FILE , O_RDONLY ) ) < 0 ) { ERROR_ERRNO ( " " ) ; exit ( EXIT_OSERROR ) ; } struct stat stat ; if ( fstat ( outfd , & stat ) < 0 ) { ERROR_ERRNO ( " " ) ; exit ( EXIT_OSERROR ) ; } outputFileSize = stat . st_size ; if ( args . osize > 0 && stat . st_size > args . osize ) { MESSAGE ( " " , stat . st_size , args . osize ) ; if ( args . stream ) { unsigned end_size = min ( 1000 , outputFileSize - args . osize ) ; if ( dump_file ( outfd , end_size , stat . st_size - end_size ) < 0 ) { ERROR ( " " ) ; exit ( EXIT_OSERROR ) ; } } else { unsigned part_size = args . osize / 2 ; if ( dump_file ( outfd , part_size , 0 ) < 0 ) { exit ( EXIT_OSERROR ) ; } if ( dump_file ( outfd , part_size , stat . st_size - part_size ) < 0 ) { exit ( EXIT_OSERROR ) ; } } } else if ( ! args . stream ) { if ( dump_file ( outfd , stat . st_size , 0 ) < 0 ) { exit ( EXIT_OSERROR ) ; } } if ( close ( outfd ) < 0 ) { ERROR_ERRNO ( " " ) ; exit ( EXIT_OSERROR ) ; } }
@brief Dumps the output of the job, truncating if necessary
@brief Dumps the output of the job truncating if necessary
// Streaming feedback: just print out the end of the output file. // We've already printed the rest to stdout. // 1 KB // Otherwise, ellide the middle half.