Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[tesh] Write self-tests in perl (we may not have cc at hand)
[simgrid.git] / tools / tesh / background.tesh
index a416496..8b177fe 100644 (file)
@@ -1,50 +1,25 @@
 
-$ rm -rf temp_testdir
-$ mkdir temp_testdir
-$ cd temp_testdir
+$ rm -rf temp_testdir_background
+$ mkdir temp_testdir_background
+$ cd temp_testdir_background
 
-< #include <unistd.h>
-< #include <stdlib.h>
-< #include <stdio.h>
-< #include <sys/types.h>
-< #include <sys/stat.h>
-< #include <fcntl.h>
-<                   
-< int main() {
-<   char buff[2048];
-<   int got;
-<   int in;
+< use strict; 
+< sleep(2);
+< open (FILE, "<tmp_fich") || die "Cannot open tmp_fich: $!\n";
 < 
-<   sleep(1);
-<   in = open("tmp_fich",O_RDONLY|O_CREAT);
-<   if (in == -1) {
-<     perror("Cannot open tmp_fich: ");
-<     exit(1);
-<   }
-<   while ((got = read(in,&buff,2048))>0) {
-<      int w = write(1,&buff,got);
-<      if (w<0) {
-<        perror("Error while writing:");
-<        exit(1);
-<      }
-<   }
-<   if (got < 0) {
-<     perror("Error while reading:");
-<     exit(1);
-<   }
-<   return 0;
+< while (<FILE>) {
+<   print;
 < }
-$ cat > delayed_cat.c
+< exit 0;
+<
+$ mkfile delayed_cat.pl
 
-$ gcc -Wall -o delayed_cat delayed_cat.c
-
-& ./delayed_cat 
+& perl delayed_cat.pl
 > TOTO
 
 < TOTO
-$ cat > tmp_fich
+$ mkfile tmp_fich
 
 $ sleep 2
 $ cd ..
-$ rm -rf temp_testdir
-
+$ rm -rf temp_testdir_background