[compiler-rt] d36d0cb - [test][sanitizer] Reformat the test

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 26 16:15:28 PDT 2023


Author: Vitaly Buka
Date: 2023-04-26T16:13:57-07:00
New Revision: d36d0cbd716a15fb1f77a3c13cd6d4aaff8b3d95

URL: https://github.com/llvm/llvm-project/commit/d36d0cbd716a15fb1f77a3c13cd6d4aaff8b3d95
DIFF: https://github.com/llvm/llvm-project/commit/d36d0cbd716a15fb1f77a3c13cd6d4aaff8b3d95.diff

LOG: [test][sanitizer] Reformat the test

Added: 
    

Modified: 
    compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp
index f46447fa388b8..201b47a7aa277 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp
@@ -9,41 +9,40 @@
 #include <stdio.h>
 #include <string.h>
 #if __linux__
-#include <pty.h>
+#  include <pty.h>
 #elif defined(__FreeBSD__)
-#include <libutil.h>
-#include <pwd.h>
-#include <sys/ioctl.h>
-#include <sys/termios.h>
-#include <sys/types.h>
+#  include <libutil.h>
+#  include <pwd.h>
+#  include <sys/ioctl.h>
+#  include <sys/termios.h>
+#  include <sys/types.h>
 #elif defined(__sun__) && defined(__svr4__)
-#include <termios.h>
+#  include <termios.h>
 #else
-#include <util.h>
+#  include <util.h>
 #endif
 #include <unistd.h>
 
-int
-main (int argc, char** argv)
-{
-    int m;
-    int pid = forkpty(&m, NULL, NULL, NULL);
+int main(int argc, char **argv) {
+  int m;
+  int pid = forkpty(&m, NULL, NULL, NULL);
 
-    if(pid == -1) {
-      fprintf(stderr, "forkpty failed\n");
-      return 1;
-    } else if (pid > 0) {
-      char buf[1024];
-      int res = read(m, buf, sizeof(buf));
+  if (pid == -1) {
+    fprintf(stderr, "forkpty failed\n");
+    return 1;
+  } else if (pid > 0) {
+    char buf[1024];
+    int res = read(m, buf, sizeof(buf));
+    write(1, buf, res);
+    write(m, "password\n", 9);
+    while ((res = read(m, buf, sizeof(buf))) > 0)
       write(1, buf, res);
-      write(m, "password\n", 9);
-      while ((res = read(m, buf, sizeof(buf))) > 0) write(1, buf, res);
-    } else {
-      char *s = getpass("prompt");
-      assert(strcmp(s, "password") == 0);
-      write(1, "done\n", 5);
-    }
-    return 0;
+  } else {
+    char *s = getpass("prompt");
+    assert(strcmp(s, "password") == 0);
+    write(1, "done\n", 5);
+  }
+  return 0;
 }
 
 // CHECK: prompt


        


More information about the llvm-commits mailing list