Similar patches for mkfifo. "mkfifo -m" was actually already implemented
although the comments in mkfifo.c said it still had to be done. The tests
are very similar to the mkdir ones.

Felix
# HG changeset patch
# User Felix Janda <felix.ja...@posteo.de>
# Date 1356627134 -3600
# Node ID 6554a8b33e82310673e775845beee9eb2c375bde
# Parent  017b8fd3c9ac5a86dd849831622c4878fddebe5d
mkfifo -m is already implemented.

diff -r 017b8fd3c9ac -r 6554a8b33e82 toys/posix/mkfifo.c
--- a/toys/posix/mkfifo.c	Wed Dec 26 19:39:51 2012 -0600
+++ b/toys/posix/mkfifo.c	Thu Dec 27 17:52:14 2012 +0100
@@ -3,8 +3,6 @@
  * Copyright 2012 Georgi Chorbadzhiyski <geo...@unixsol.org>
  *
  * See http://opengroup.org/onlinepubs/9699919799/utilities/mkfifo.html
- *
- * TODO: Add -m
 
 USE_MKFIFO(NEWTOY(mkfifo, "<1m:", TOYFLAG_BIN))
 
@@ -30,9 +28,7 @@
   char **s;
 
   TT.mode = 0666;
-  if (toys.optflags & FLAG_m) {
-    TT.mode = string_to_mode(TT.m_string, 0);
-  }
+  if (toys.optflags & FLAG_m) TT.mode = string_to_mode(TT.m_string, 0);
 
   for (s = toys.optargs; *s; s++) {
     if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) {
# HG changeset patch
# User Felix Janda <felix.ja...@posteo.de>
# Date 1356627321 -3600
# Node ID 7b602ab6a797d57aedccf9bc69963eccbef57055
# Parent  017b8fd3c9ac5a86dd849831622c4878fddebe5d
Add tests to mkfifo based on tests for mkdir.

diff --git a/scripts/test/mkfifo.test b/scripts/test/mkfifo.test
new file mode 100755
--- /dev/null
+++ b/scripts/test/mkfifo.test
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+testing "mkfifo" "mkfifo one && [ -p one ] && echo yes" "yes\n" "" ""
+rm one
+
+touch existing
+testing "mkfifo existing" \
+	"mkfifo existing 2> /dev/null || [ -f existing ] && echo yes" "yes\n" "" ""
+rm existing
+
+testing "mkfifo one two" \
+	"mkfifo one two && [ -p one ] && [ -p two ] && echo yes" "yes\n" "" ""
+rm one two
+
+umask 123
+testing "mkfifo (default permissions)" \
+	"mkfifo one && stat -c %a one" "644\n" "" ""
+rm one
+
+umask 000
+
+testing "mkfifo -m 124" \
+	"mkfifo -m 124 one && stat -c %a one" "124\n" "" ""
+rm -f one
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to