Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: subprocess_unittest.cc

Issue 3199015: Don't generate quitquitquit files when running unit tests. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: save one line Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « .gitignore ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sys/stat.h> 5 #include <sys/stat.h>
6 #include <sys/types.h> 6 #include <sys/types.h>
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 Subprocess::Get().CancelExec(tag); 87 Subprocess::Get().CancelExec(tag);
88 return FALSE; 88 return FALSE;
89 } 89 }
90 } // namespace {} 90 } // namespace {}
91 91
92 gboolean ExitWhenDone(gpointer data) { 92 gboolean ExitWhenDone(gpointer data) {
93 CancelTestData* cancel_test_data = reinterpret_cast<CancelTestData*>(data); 93 CancelTestData* cancel_test_data = reinterpret_cast<CancelTestData*>(data);
94 if (cancel_test_data->spawned && !Subprocess::Get().SubprocessInFlight()) { 94 if (cancel_test_data->spawned && !Subprocess::Get().SubprocessInFlight()) {
95 // tear down the sub process 95 // tear down the sub process
96 printf("tear down time\n"); 96 printf("tear down time\n");
97 int status = 97 int status = System(
98 System(StringPrintf("wget http://127.0.0.1:%d/quitquitquit", 98 StringPrintf("wget -O /dev/null http://127.0.0.1:%d/quitquitquit",
99 kLocalHttpPort)); 99 kLocalHttpPort));
100 EXPECT_NE(-1, status) << "system() failed"; 100 EXPECT_NE(-1, status) << "system() failed";
101 EXPECT_TRUE(WIFEXITED(status)) 101 EXPECT_TRUE(WIFEXITED(status))
102 << "command failed to run or died abnormally"; 102 << "command failed to run or died abnormally";
103 g_main_loop_quit(cancel_test_data->loop); 103 g_main_loop_quit(cancel_test_data->loop);
104 return FALSE; 104 return FALSE;
105 } 105 }
106 return TRUE; 106 return TRUE;
107 } 107 }
108 108
109 TEST(SubprocessTest, CancelTest) { 109 TEST(SubprocessTest, CancelTest) {
110 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); 110 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
111 CancelTestData cancel_test_data; 111 CancelTestData cancel_test_data;
112 cancel_test_data.spawned = false; 112 cancel_test_data.spawned = false;
113 cancel_test_data.loop = loop; 113 cancel_test_data.loop = loop;
114 g_timeout_add(100, &StartAndCancelInRunLoop, &cancel_test_data); 114 g_timeout_add(100, &StartAndCancelInRunLoop, &cancel_test_data);
115 g_timeout_add(10, &ExitWhenDone, &cancel_test_data); 115 g_timeout_add(10, &ExitWhenDone, &cancel_test_data);
116 g_main_loop_run(loop); 116 g_main_loop_run(loop);
117 g_main_loop_unref(loop); 117 g_main_loop_unref(loop);
118 printf("here\n"); 118 printf("here\n");
119 } 119 }
120 120
121 } // namespace chromeos_update_engine 121 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « .gitignore ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698