Repository: mesos
Updated Branches:
  refs/heads/master b99ca4d73 -> fe09d7de7


Eliminate use of 'echo -n'

Review: https://reviews.apache.org/r/32898


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fbfe3fac
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fbfe3fac
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fbfe3fac

Branch: refs/heads/master
Commit: fbfe3facd035d3d372139d1c62f0b30632480956
Parents: b99ca4d
Author: Paul Brett <[email protected]>
Authored: Tue Apr 7 10:27:52 2015 -0700
Committer: Ian Downes <[email protected]>
Committed: Tue Apr 7 10:27:52 2015 -0700

----------------------------------------------------------------------
 src/tests/port_mapping_tests.cpp | 42 +++++++++++++++++------------------
 support/timed_tests.sh           |  4 ++--
 2 files changed, 23 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/fbfe3fac/src/tests/port_mapping_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/port_mapping_tests.cpp b/src/tests/port_mapping_tests.cpp
index 55a5e69..36219e7 100644
--- a/src/tests/port_mapping_tests.cpp
+++ b/src/tests/port_mapping_tests.cpp
@@ -508,13 +508,13 @@ TEST_F(PortMappingIsolatorTest, 
ROOT_ContainerToContainerTCPTest)
   ostringstream command2;
 
   // Send to 'localhost' and 'port'.
-  command2 << "echo -n hello1 | nc localhost " << port << ";";
+  command2 << "printf hello1 | nc localhost " << port << ";";
   // Send to 'localhost' and 'errorPort'. This should fail.
-  command2 << "echo -n hello2 | nc localhost " << errorPort << ";";
+  command2 << "printf hello2 | nc localhost " << errorPort << ";";
   // Send to 'public IP' and 'port'.
-  command2 << "echo -n hello3 | nc " << hostIP << " " << port << ";";
+  command2 << "printf hello3 | nc " << hostIP << " " << port << ";";
   // Send to 'public IP' and 'errorPort'. This should fail.
-  command2 << "echo -n hello4 | nc " << hostIP << " " << errorPort << ";";
+  command2 << "printf hello4 | nc " << hostIP << " " << errorPort << ";";
   // Touch the guard file.
   command2 << "touch " << container2Ready;
 
@@ -657,13 +657,13 @@ TEST_F(PortMappingIsolatorTest, 
ROOT_ContainerToContainerUDPTest)
   ostringstream command2;
 
   // Send to 'localhost' and 'port'.
-  command2 << "echo -n hello1 | nc -w1 -u localhost " << port << ";";
+  command2 << "printf hello1 | nc -w1 -u localhost " << port << ";";
   // Send to 'localhost' and 'errorPort'. No data should be sent.
-  command2 << "echo -n hello2 | nc -w1 -u localhost " << errorPort << ";";
+  command2 << "printf hello2 | nc -w1 -u localhost " << errorPort << ";";
   // Send to 'public IP' and 'port'.
-  command2 << "echo -n hello3 | nc -w1 -u " << hostIP << " " << port << ";";
+  command2 << "printf hello3 | nc -w1 -u " << hostIP << " " << port << ";";
   // Send to 'public IP' and 'errorPort'. No data should be sent.
-  command2 << "echo -n hello4 | nc -w1 -u " << hostIP << " " << errorPort
+  command2 << "printf hello4 | nc -w1 -u " << hostIP << " " << errorPort
            << ";";
   // Touch the guard file.
   command2 << "touch " << container2Ready;
@@ -792,24 +792,24 @@ TEST_F(PortMappingIsolatorTest, 
ROOT_HostToContainerUDPTest)
 
   // Send to 'localhost' and 'port'.
   ostringstream command2;
-  command2 << "echo -n hello1 | nc -w1 -u localhost " << port;
+  command2 << "printf hello1 | nc -w1 -u localhost " << port;
   ASSERT_SOME_EQ(0, os::shell(NULL, command2.str().c_str()));
 
   // Send to 'localhost' and 'errorPort'. The command should return
   // successfully because UDP is stateless but no data could be sent.
   ostringstream command3;
-  command3 << "echo -n hello2 | nc -w1 -u localhost " << errorPort;
+  command3 << "printf hello2 | nc -w1 -u localhost " << errorPort;
   ASSERT_SOME_EQ(0, os::shell(NULL, command3.str().c_str()));
 
   // Send to 'public IP' and 'port'.
   ostringstream command4;
-  command4 << "echo -n hello3 | nc -w1 -u " << hostIP << " " << port;
+  command4 << "printf hello3 | nc -w1 -u " << hostIP << " " << port;
   ASSERT_SOME_EQ(0, os::shell(NULL, command4.str().c_str()));
 
   // Send to 'public IP' and 'errorPort'. The command should return
   // successfully because UDP is stateless but no data could be sent.
   ostringstream command5;
-  command5 << "echo -n hello4 | nc -w1 -u " << hostIP << " " << errorPort;
+  command5 << "printf hello4 | nc -w1 -u " << hostIP << " " << errorPort;
   ASSERT_SOME_EQ(0, os::shell(NULL, command5.str().c_str()));
 
   EXPECT_SOME_EQ("hello1", os::read(trafficViaLoopback));
@@ -902,24 +902,24 @@ TEST_F(PortMappingIsolatorTest, 
ROOT_HostToContainerTCPTest)
 
   // Send to 'localhost' and 'port'.
   ostringstream command2;
-  command2 << "echo -n hello1 | nc localhost " << port;
+  command2 << "printf hello1 | nc localhost " << port;
   ASSERT_SOME_EQ(0, os::shell(NULL, command2.str().c_str()));
 
   // Send to 'localhost' and 'errorPort'. This should fail because TCP
   // connection couldn't be established..
   ostringstream command3;
-  command3 << "echo -n hello2 | nc localhost " << errorPort;
+  command3 << "printf hello2 | nc localhost " << errorPort;
   ASSERT_SOME_EQ(256, os::shell(NULL, command3.str().c_str()));
 
   // Send to 'public IP' and 'port'.
   ostringstream command4;
-  command4 << "echo -n hello3 | nc " << hostIP << " " << port;
+  command4 << "printf hello3 | nc " << hostIP << " " << port;
   ASSERT_SOME_EQ(0, os::shell(NULL, command4.str().c_str()));
 
   // Send to 'public IP' and 'errorPort'. This should fail because TCP
   // connection couldn't be established.
   ostringstream command5;
-  command5 << "echo -n hello4 | nc " << hostIP << " " << errorPort;
+  command5 << "printf hello4 | nc " << hostIP << " " << errorPort;
   ASSERT_SOME_EQ(256, os::shell(NULL, command5.str().c_str()));
 
   EXPECT_SOME_EQ("hello1", os::read(trafficViaLoopback));
@@ -981,7 +981,7 @@ TEST_F(PortMappingIsolatorTest, 
ROOT_ContainerICMPExternalTest)
       command1 << " && ";
     }
   }
-  command1 << "; echo -n $? > " << exitStatus << "; sync";
+  command1 << "; printf $? > " << exitStatus << "; sync";
 
   int pipes[2];
   ASSERT_NE(-1, ::pipe(pipes));
@@ -1054,8 +1054,8 @@ TEST_F(PortMappingIsolatorTest, 
ROOT_ContainerICMPInternalTest)
   ASSERT_SOME(preparation1.get());
 
   ostringstream command1;
-  command1 << "ping -c1 127.0.0.1 && ping -c1 " << hostIP << "; echo -n $? > "
-           << exitStatus << "; sync";
+  command1 << "ping -c1 127.0.0.1 && ping -c1 " << hostIP
+           << "; printf $? > " << exitStatus << "; sync";
 
   int pipes[2];
   ASSERT_NE(-1, ::pipe(pipes));
@@ -1145,7 +1145,7 @@ TEST_F(PortMappingIsolatorTest, 
ROOT_ContainerARPExternalTest)
       command1 << " && ";
     }
   }
-  command1 << "; echo -n $? > " << exitStatus << "; sync";
+  command1 << "; printf $? > " << exitStatus << "; sync";
 
   int pipes[2];
   ASSERT_NE(-1, ::pipe(pipes));
@@ -1233,7 +1233,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_DNSTest)
       command1 << " && ";
     }
   }
-  command1 << "; echo -n $? > " << exitStatus << "; sync";
+  command1 << "; printf $? > " << exitStatus << "; sync";
 
   int pipes[2];
   ASSERT_NE(-1, ::pipe(pipes));

http://git-wip-us.apache.org/repos/asf/mesos/blob/fbfe3fac/support/timed_tests.sh
----------------------------------------------------------------------
diff --git a/support/timed_tests.sh b/support/timed_tests.sh
index 5e01af9..37e30ef 100755
--- a/support/timed_tests.sh
+++ b/support/timed_tests.sh
@@ -34,7 +34,7 @@ duration=$2
 
 echo "This script runs with session id $$ and can be terminated by: pkill -s 
$$"
 
-echo -n `date`; echo ": start running $test_cmd"
+printf "$(date)"; echo ": start running $test_cmd"
 
 start=$(date +"%s")
 eval $test_cmd &
@@ -55,7 +55,7 @@ while [ $(($(date +"%s") - $start)) -lt $duration ]; do
   sleep 5
 done
 
-echo -n `date`; echo ": process still running after $duration seconds"
+printf "$(date)"; echo ": process still running after $duration seconds"
 
 tmp=`mktemp XXXXX`
 echo "thread apply all bt" > $tmp

Reply via email to