From 30720e3f4ca6bcd145cb644358a5e1bfcd795864 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Wed, 4 Sep 2002 18:42:14 +0000 Subject: [PATCH] condensed test svn path=/trunk/boinc/; revision=404 --- apps/Makefile.in | 13 +---- apps/concat.C | 104 ++++++++++++++++++++++++++++++---- apps/concat_slow.C | 132 ------------------------------------------- checkin_notes | 6 +- test/test_concat.php | 12 +++- 5 files changed, 107 insertions(+), 160 deletions(-) delete mode 100644 apps/concat_slow.C diff --git a/apps/Makefile.in b/apps/Makefile.in index 146c8e78e8..18c2aa6534 100644 --- a/apps/Makefile.in +++ b/apps/Makefile.in @@ -17,7 +17,7 @@ LIBS = ../api/boinc_api.o ../api/mfile.o ../lib/parse.o ../lib/filesys.o ../lib/ CLIBS = @LIBS@ -APPS = upper_case concat uc_slow concat_slow 1sec uc_cpu +APPS = upper_case concat 1sec .C.o: $(CC) -c -o $*.o $< @@ -32,15 +32,6 @@ upper_case: upper_case.o concat: concat.o $(CC) concat.o $(LIBS) -o concat -concat_slow: concat_slow.o - $(CC) concat_slow.o $(LIBS) -o concat_slow - -uc_slow: uc_slow.o - $(CC) uc_slow.o $(LIBS) -o uc_slow - -uc_cpu: uc_cpu.o - $(CC) uc_cpu.o $(LIBS) -o uc_cpu - 1sec: 1sec.o $(CC) 1sec.o $(LIBS) -o 1sec @@ -48,8 +39,6 @@ install: all -mkdir -p $(INSTALL_DIR)/apps cp upper_case $(INSTALL_DIR)/apps/upper_case cp concat $(INSTALL_DIR)/apps/concat - cp uc_slow $(INSTALL_DIR)/apps/uc_slow - cp concat_slow $(INSTALL_DIR)/apps/concat_slow cp 1sec $(INSTALL_DIR)/apps/1sec uninstall: diff --git a/apps/concat.C b/apps/concat.C index 4498f24301..c84bbe27e2 100644 --- a/apps/concat.C +++ b/apps/concat.C @@ -17,43 +17,122 @@ // Contributor(s): // -// concat file1 ... filen outfile +// concat [-run_slow] file1 ... filen outfile // // concatenate files, write to outfile #include #include +#include + +#include "filesys.h" #include "boinc_api.h" -void file_append(FILE* in, FILE* out) { - char buf[1024]; - int n; +int run_slow = 0; + +#define CHECKPOINT_FILE "concat_state" + +int do_checkpoint(MFILE& mf, int filenum, int nchars ) { + int retval; + char resolved_name[512],res_name2[512]; + + FILE* f = fopen("temp", "w"); + if (!f) return 1; + fprintf(f, "%d %d", filenum, nchars); + fclose(f); + + fprintf(stderr, "APP: concat checkpointing\n"); + + boinc_resolve_filename( CHECKPOINT_FILE, res_name2 ); + + retval = mf.flush(); + if (retval) return retval; + retval = boinc_rename("temp", res_name2); + if (retval) return retval; + + return 0; +} + +void file_append(FILE* in, MFILE &out, int skip, int filenum) { + char buf[1]; + int n,nread,retval; + + fseek( in, skip, SEEK_SET ); + nread = skip; while (1) { - n = fread(buf, 1, 1024, in); + n = fread(buf, 1, 1, in); if (n == 0) break; - fwrite(buf, 1, n, out); + out.write(buf, 1, n); + nread += n; + + if( boinc_time_to_checkpoint() ) { + fprintf( stderr, "Checkpoint.\n" ); + retval = do_checkpoint( out, filenum, nread ); + if( retval ) { + fprintf( stderr, "APP: concat checkpoint failed %d\n", retval ); + exit(1); + } + boinc_checkpoint_completed(); + } + + if (run_slow) sleep(1); } } +#ifdef _WIN32 +#include +int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int WinMode) { + LPWSTR command_line; + LPWSTR *args; + char* argv[100]; + int i, argc; + + command_line = GetCommandLineW(); + args = CommandLineToArgvW(command_line, &argc); + + // uh, why did MS have to "improve" on char*? + + for (i=0; i -#include -#include - -#include "filesys.h" -#include "boinc_api.h" - -#define CHECKPOINT_FILE "concat_slow_state" - -int do_checkpoint(MFILE& mf, int filenum, int nchars ) { - int retval; - char resolved_name[512],res_name2[512]; - - FILE* f = fopen("temp", "w"); - if (!f) return 1; - fprintf(f, "%d %d", filenum, nchars); - fclose(f); - - fprintf(stderr, "APP: concat_slow checkpointing\n"); - - boinc_resolve_filename( CHECKPOINT_FILE, res_name2 ); - - retval = mf.flush(); - if (retval) return retval; - retval = boinc_rename("temp", res_name2); - if (retval) return retval; - - return 0; -} - -void file_append(FILE* in, MFILE &out, int skip, int filenum) { - char buf[1]; - int n,nread,retval; - - fseek( in, skip, SEEK_SET ); - nread = skip; - - while (1) { - n = fread(buf, 1, 1, in); - if (n == 0) break; - out.write(buf, 1, n); - nread += n; - fprintf( stderr, "Wrote 1 char.\n" ); - // Burn cycles - for( n=0;n<5000000;n++ ) - retval += n; - if( retval == 0 ) - n = 1; - - if( boinc_time_to_checkpoint() ) { - fprintf( stderr, "Checkpoint.\n" ); - retval = do_checkpoint( out, filenum, nread ); - if( retval ) { - fprintf( stderr, "APP: concat_slow checkpoint failed %d\n", retval ); - exit(1); - } - boinc_checkpoint_completed(); - } - sleep(1); - } -} - -int main(int argc, char** argv) { - FILE* in, *state; - MFILE out; - char file_name[512]; - int i; - int file_num,nchars,retval; - char *mode; - - boinc_init(); - fprintf(stderr, "APP: concat: starting, argc %d\n", argc); - for (i=0; i