Browse Source

Hehe make environment tests work for everybody

jD91mZM2 6 years ago
parent
commit
515d041153
3 changed files with 5 additions and 14 deletions
  1. 4 4
      tests/env.c
  2. 1 3
      tests/expected/env.stdout
  3. 0 7
      tests/pipe.c

+ 4 - 4
tests/env.c

@@ -2,10 +2,10 @@
 #include <stdlib.h>
 #include <stdlib.h>
 
 
 int main() {
 int main() {
-    puts(getenv("SHELL"));
-    puts(getenv("CC"));
+    //puts(getenv("SHELL"));
+    //puts(getenv("CC"));
 
 
-    putenv("KEK=lol");
+    putenv("TEST=It's working!!");
 
 
-    puts(getenv("KEK"));
+    puts(getenv("TEST"));
 }
 }

+ 1 - 3
tests/expected/env.stdout

@@ -1,3 +1 @@
-/nix/store/zqh3l3lyw32q1ayb15bnvg9f24j5v2p0-bash-4.4-p12/bin/bash
-gcc
-lol
+It's working!!

+ 0 - 7
tests/pipe.c

@@ -1,5 +1,4 @@
 //http://www2.cs.uregina.ca/~hamilton/courses/330/notes/unix/pipes/pipes.html
 //http://www2.cs.uregina.ca/~hamilton/courses/330/notes/unix/pipes/pipes.html
-#include <stdio.h>
 #include <string.h>
 #include <string.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
@@ -15,25 +14,19 @@ int main()
     pid = fork();
     pid = fork();
     if (pid == 0)           /* child : sends message to parent*/
     if (pid == 0)           /* child : sends message to parent*/
     {
     {
-        puts("Child: Close Read");
         /* close read end */
         /* close read end */
         close(pip[0]);
         close(pip[0]);
-        puts("Child: Write");
         /* send 7 characters in the string, including end-of-string */
         /* send 7 characters in the string, including end-of-string */
         write(pip[1], outstring, strlen(outstring));
         write(pip[1], outstring, strlen(outstring));
-        puts("Child: Close Write");
         /* close write end */
         /* close write end */
         close(pip[1]);
         close(pip[1]);
     }
     }
     else			/* parent : receives message from child */
     else			/* parent : receives message from child */
     {
     {
-        puts("Parent: Close Write");
         /* close write end */
         /* close write end */
         close(pip[1]);
         close(pip[1]);
-        puts("Parent: Read");
         /* read from the pipe */
         /* read from the pipe */
         read(pip[0], instring, 7);
         read(pip[0], instring, 7);
-        puts("Parent: Close Read");
         /* close read end */
         /* close read end */
         close(pip[0]);
         close(pip[0]);
     }
     }