| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 struct CancelTestData { | 56 struct CancelTestData { |
| 57 bool spawned; | 57 bool spawned; |
| 58 GMainLoop *loop; | 58 GMainLoop *loop; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 gboolean StartAndCancelInRunLoop(gpointer data) { | 61 gboolean StartAndCancelInRunLoop(gpointer data) { |
| 62 CancelTestData* cancel_test_data = reinterpret_cast<CancelTestData*>(data); | 62 CancelTestData* cancel_test_data = reinterpret_cast<CancelTestData*>(data); |
| 63 vector<string> cmd; | 63 vector<string> cmd; |
| 64 cmd.push_back("./test_http_server"); | 64 cmd.push_back("./test_http_server"); |
| 65 uint32 tag = Subprocess::Get().Exec(cmd, CallbackBad, NULL); | 65 uint32_t tag = Subprocess::Get().Exec(cmd, CallbackBad, NULL); |
| 66 EXPECT_NE(0, tag); | 66 EXPECT_NE(0, tag); |
| 67 cancel_test_data->spawned = true; | 67 cancel_test_data->spawned = true; |
| 68 printf("spawned\n"); | 68 printf("spawned\n"); |
| 69 // Wait for server to be up and running | 69 // Wait for server to be up and running |
| 70 for (;;) { | 70 for (;;) { |
| 71 int status = | 71 int status = |
| 72 System(StringPrintf("wget -O /dev/null http://127.0.0.1:%d/foo", | 72 System(StringPrintf("wget -O /dev/null http://127.0.0.1:%d/foo", |
| 73 kLocalHttpPort)); | 73 kLocalHttpPort)); |
| 74 EXPECT_NE(-1, status) << "system() failed"; | 74 EXPECT_NE(-1, status) << "system() failed"; |
| 75 EXPECT_TRUE(WIFEXITED(status)) | 75 EXPECT_TRUE(WIFEXITED(status)) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 106 cancel_test_data.spawned = false; | 106 cancel_test_data.spawned = false; |
| 107 cancel_test_data.loop = loop; | 107 cancel_test_data.loop = loop; |
| 108 g_timeout_add(100, &StartAndCancelInRunLoop, &cancel_test_data); | 108 g_timeout_add(100, &StartAndCancelInRunLoop, &cancel_test_data); |
| 109 g_timeout_add(10, &ExitWhenDone, &cancel_test_data); | 109 g_timeout_add(10, &ExitWhenDone, &cancel_test_data); |
| 110 g_main_loop_run(loop); | 110 g_main_loop_run(loop); |
| 111 g_main_loop_unref(loop); | 111 g_main_loop_unref(loop); |
| 112 printf("here\n"); | 112 printf("here\n"); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace chromeos_update_engine | 115 } // namespace chromeos_update_engine |
| OLD | NEW |