Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 2015, Google Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 34 | #include <sys/signal.h> |
| 35 | |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 36 | #include <chrono> |
| 37 | #include <thread> |
| 38 | |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 39 | #include <grpc/grpc.h> |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 40 | #include <gflags/gflags.h> |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 41 | |
| 42 | #include "qps_worker.h" |
Yang Gao | 103837e | 2015-04-15 15:23:54 -0700 | [diff] [blame] | 43 | #include "test/cpp/util/test_config.h" |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 44 | |
| 45 | DEFINE_int32(driver_port, 0, "Driver server port."); |
| 46 | DEFINE_int32(server_port, 0, "Spawned server port."); |
| 47 | |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 48 | static bool got_sigint = false; |
| 49 | |
Vijay Pai | f2554d0 | 2015-04-02 13:58:27 -0700 | [diff] [blame] | 50 | static void sigint_handler(int x) {got_sigint = true;} |
| 51 | |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 52 | namespace grpc { |
| 53 | namespace testing { |
| 54 | |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 55 | static void RunServer() { |
Craig Tiller | e9a6eb7 | 2015-04-09 15:51:41 -0700 | [diff] [blame] | 56 | QpsWorker worker(FLAGS_driver_port, FLAGS_server_port); |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 57 | |
| 58 | while (!got_sigint) { |
| 59 | std::this_thread::sleep_for(std::chrono::seconds(5)); |
| 60 | } |
| 61 | } |
| 62 | |
Craig Tiller | 10923c2 | 2015-03-03 14:24:49 -0800 | [diff] [blame] | 63 | } // namespace testing |
| 64 | } // namespace grpc |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 65 | |
Craig Tiller | 10923c2 | 2015-03-03 14:24:49 -0800 | [diff] [blame] | 66 | int main(int argc, char** argv) { |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 67 | grpc_init(); |
Yang Gao | 103837e | 2015-04-15 15:23:54 -0700 | [diff] [blame] | 68 | grpc::testing::InitTest(&argc, &argv, true); |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 69 | |
Vijay Pai | f2554d0 | 2015-04-02 13:58:27 -0700 | [diff] [blame] | 70 | signal(SIGINT, sigint_handler); |
| 71 | |
Craig Tiller | 26598a3 | 2015-03-02 16:16:00 -0800 | [diff] [blame] | 72 | grpc::testing::RunServer(); |
| 73 | |
| 74 | grpc_shutdown(); |
| 75 | return 0; |
| 76 | } |