[klee-commits] [1522] Adding an --one-line-streams option to the models.

cristic at stanford.edu cristic at stanford.edu
Mon Mar 30 23:09:30 PDT 2009


Revision: 1522
          http://keeda.stanford.edu/viewvc/viewvc.cgi?view=rev&revision=1522
Author:   cristic
Date:     2009-03-30 23:09:29 -0700 (Mon, 30 Mar 2009)
Log Message:
-----------
Adding an --one-line-streams option to the models.
We should provide less intrusive support for such options.

Modified Paths:
--------------
    models/simple/fd.h
    models/simple/fd_init.c
    models/simple/klee_init_env.c

Modified: models/simple/fd.h
===================================================================
--- models/simple/fd.h	2009-03-31 06:03:41 UTC (rev 1521)
+++ models/simple/fd.h	2009-03-31 06:09:29 UTC (rev 1522)
@@ -75,7 +75,8 @@
 void klee_init_fds(unsigned n_files, unsigned file_length, 
 		   int sym_stdout_flag, int do_all_writes_flag, 
 		   unsigned n_conns, unsigned conn_len,
-		   unsigned max_failures);
+		   unsigned max_failures,
+		   int one_line_streams);
 void klee_init_env(int *argcPtr, char ***argvPtr);
 
 /* Returns next available fd.  Sets eOpen in associated flags.  

Modified: models/simple/fd_init.c
===================================================================
--- models/simple/fd_init.c	2009-03-31 06:03:41 UTC (rev 1521)
+++ models/simple/fd_init.c	2009-03-31 06:09:29 UTC (rev 1522)
@@ -34,12 +34,19 @@
   0
 };
 
+
+
+/* XXX: We should provide better support for such options! */
+static int __one_line_streams = 0;
+
+
 static void __create_new_dfile(exe_disk_file_t *dfile, unsigned size,
                                const char *name, struct stat64 *defaults,
 			       int is_conn) {
   struct stat64 *s = malloc(sizeof(*s));
   const char *sp;
   char data_name[64], stat_name[64], conn_name[64];
+  unsigned i;
 
   for (sp=name; *sp; ++sp)
     data_name[sp-name] = *sp;
@@ -53,6 +60,16 @@
   dfile->contents = malloc(dfile->size);
   klee_make_symbolic_name(dfile->contents, dfile->size, data_name);
 
+  /* XXX: We should provide better support for such options! */
+  if (__one_line_streams && dfile->size) {
+    for (i=0; i < dfile->size-1; i++)
+      if (dfile->contents[i] == '\n')
+	klee_silent_exit(0);
+    
+    if (dfile->contents[dfile->size-1] != '\n')
+      klee_silent_exit(0);
+  }
+
   klee_make_symbolic_name(s, sizeof(*s), stat_name);
 
   /* For broken tests */
@@ -119,13 +136,16 @@
 void klee_init_fds(unsigned n_files, unsigned file_length,
 		   int sym_stdout_flag, int save_all_writes_flag,
 		   unsigned n_conns, unsigned conn_len,
-		   unsigned max_failures) {
+		   unsigned max_failures,
+		   int one_line_streams) {
   unsigned k;
   char name[] = "?";
   struct stat64 s;
 
   stat64(".", &s);
 
+  __one_line_streams = one_line_streams;
+
   __exe_fs.n_sym_files = n_files;
   __exe_fs.sym_files = malloc(sizeof(*__exe_fs.sym_files) * n_files);
   for (k=0; k < n_files; k++) {

Modified: models/simple/klee_init_env.c
===================================================================
--- models/simple/klee_init_env.c	2009-03-31 06:03:41 UTC (rev 1521)
+++ models/simple/klee_init_env.c	2009-03-31 06:09:29 UTC (rev 1522)
@@ -82,6 +82,7 @@
   unsigned sym_conns = 0, sym_conn_len = 0;
   int sym_stdout_flag = 0;
   int save_all_writes_flag = 0;
+  int one_line_streams_flag = 0;
   int fd_fail = 0;
   char** final_argv;
   char sym_arg_name[5] = "arg";
@@ -163,6 +164,10 @@
       sym_conn_len = __str_to_int(argv[k++], msg);
 
     }
+    else if (__streq(argv[k], "--one-line-streams") || __streq(argv[k], "-one-line-streams")) {
+      one_line_streams_flag = 1;
+      k++;
+    }
     else {
       /* simply copy arguments */
       __add_arg(&new_argc, new_argv, argv[k++], 1024);
@@ -180,6 +185,6 @@
   klee_init_fds(sym_files, sym_file_len, 
 		sym_stdout_flag, save_all_writes_flag,
 		sym_conns, sym_conn_len,
-		fd_fail);
+		fd_fail, one_line_streams_flag);
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://keeda.Stanford.EDU/pipermail/klee-commits/attachments/20090330/bbf11952/attachment-0001.html 


More information about the klee-commits mailing list