summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-11-05 18:56:12 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-11-08 14:26:00 +0100
commit23fb7b2cbbda62c99a199d29ad62205b23d35af4 (patch)
tree5bd5ea69491b9d8234ccb72a8767c41b4fc17acf
parentad5ffe1ffb203eb58e5e25fe6f4c0dabc53253c9 (diff)
(style) Variable 'res' is assigned a value that is never used
Checking the return value of this (and many other calls) in this testcase is a good idea, so we do it now. Reported-By: cppcheck Git-Dch: Ignore
-rw-r--r--test/libapt/fileutl_test.cc29
1 files changed, 16 insertions, 13 deletions
diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc
index 57d5bbdc2..a2c303768 100644
--- a/test/libapt/fileutl_test.cc
+++ b/test/libapt/fileutl_test.cc
@@ -252,37 +252,40 @@ TEST(FileUtlTest, Popen)
// output something
const char* Args[10] = {"/bin/echo", "meepmeep", NULL};
- bool res = Popen(Args, Fd, Child, FileFd::ReadOnly);
- Fd.Read(buf, sizeof(buf)-1, &n);
+ EXPECT_TRUE(Popen(Args, Fd, Child, FileFd::ReadOnly));
+ EXPECT_TRUE(Fd.Read(buf, sizeof(buf)-1, &n));
buf[n] = 0;
EXPECT_NE(n, 0);
- EXPECT_EQ(res, true);
EXPECT_STREQ(buf, "meepmeep\n");
// wait for the child to exit and cleanup
- ExecWait(Child, "PopenRead");
- Fd.Close();
+ EXPECT_TRUE(ExecWait(Child, "PopenRead"));
+ EXPECT_TRUE(Fd.Close());
// ensure that after a close all is good again
if(FileExists("/proc/self/fd"))
EXPECT_EQ(Glob("/proc/self/fd/*").size(), OpenFds.size());
-
// ReadWrite is not supported
- res = Popen(Args, Fd, Child, FileFd::ReadWrite);
- EXPECT_EQ(res, false);
- _error->Discard();
+ _error->PushToStack();
+ EXPECT_FALSE(Popen(Args, Fd, Child, FileFd::ReadWrite));
+ EXPECT_FALSE(Fd.IsOpen());
+ EXPECT_FALSE(Fd.Failed());
+ EXPECT_TRUE(_error->PendingError());
+ _error->RevertToStack();
// write something
Args[0] = "/bin/bash";
Args[1] = "-c";
Args[2] = "read";
Args[3] = NULL;
- res = Popen(Args, Fd, Child, FileFd::WriteOnly);
+ EXPECT_TRUE(Popen(Args, Fd, Child, FileFd::WriteOnly));
s = "\n";
- Fd.Write(s.c_str(), s.size());
- Fd.Close();
- ExecWait(Child, "PopenWrite");
+ EXPECT_TRUE(Fd.Write(s.c_str(), s.length()));
+ EXPECT_TRUE(Fd.Close());
+ EXPECT_FALSE(Fd.IsOpen());
+ EXPECT_FALSE(Fd.Failed());
+ EXPECT_TRUE(ExecWait(Child, "PopenWrite"));
}
TEST(FileUtlTest, flAbsPath)
{