protocol.cc 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  2. *
  3. * Gearmand client and server library.
  4. *
  5. * Copyright (C) 2011 Data Differential, http://datadifferential.com/
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions are
  10. * met:
  11. *
  12. * * Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * * Redistributions in binary form must reproduce the above
  16. * copyright notice, this list of conditions and the following disclaimer
  17. * in the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * * The names of its contributors may not be used to endorse or
  21. * promote products derived from this software without specific prior
  22. * written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. */
  37. #include "gear_config.h"
  38. #include <libtest/test.hpp>
  39. using namespace libtest;
  40. #include <cassert>
  41. #include <cstring>
  42. #include <libgearman/gearman.h>
  43. #include <tests/protocol.h>
  44. #ifndef __INTEL_COMPILER
  45. #pragma GCC diagnostic ignored "-Wold-style-cast"
  46. #endif
  47. test_return_t check_gearman_command_t(void *)
  48. {
  49. ASSERT_EQ(0, int(GEARMAN_COMMAND_TEXT));
  50. ASSERT_EQ(1, int(GEARMAN_COMMAND_CAN_DO));
  51. ASSERT_EQ(2, int(GEARMAN_COMMAND_CANT_DO));
  52. ASSERT_EQ(3, int(GEARMAN_COMMAND_RESET_ABILITIES));
  53. ASSERT_EQ(4, int(GEARMAN_COMMAND_PRE_SLEEP));
  54. ASSERT_EQ(5, int(GEARMAN_COMMAND_UNUSED));
  55. ASSERT_EQ(6, int(GEARMAN_COMMAND_NOOP));
  56. ASSERT_EQ(7, int(GEARMAN_COMMAND_SUBMIT_JOB));
  57. ASSERT_EQ(8, int(GEARMAN_COMMAND_JOB_CREATED));
  58. ASSERT_EQ(9, int(GEARMAN_COMMAND_GRAB_JOB));
  59. ASSERT_EQ(10, int(GEARMAN_COMMAND_NO_JOB));
  60. ASSERT_EQ(11, int(GEARMAN_COMMAND_JOB_ASSIGN));
  61. ASSERT_EQ(12, int(GEARMAN_COMMAND_WORK_STATUS));
  62. ASSERT_EQ(13, int(GEARMAN_COMMAND_WORK_COMPLETE));
  63. ASSERT_EQ(14, int(GEARMAN_COMMAND_WORK_FAIL));
  64. ASSERT_EQ(15, int(GEARMAN_COMMAND_GET_STATUS));
  65. ASSERT_EQ(16, int(GEARMAN_COMMAND_ECHO_REQ));
  66. ASSERT_EQ(17, int(GEARMAN_COMMAND_ECHO_RES));
  67. ASSERT_EQ(18, int(GEARMAN_COMMAND_SUBMIT_JOB_BG));
  68. ASSERT_EQ(19, int(GEARMAN_COMMAND_ERROR));
  69. ASSERT_EQ(20, int(GEARMAN_COMMAND_STATUS_RES));
  70. ASSERT_EQ(21, int(GEARMAN_COMMAND_SUBMIT_JOB_HIGH));
  71. ASSERT_EQ(22, int(GEARMAN_COMMAND_SET_CLIENT_ID));
  72. ASSERT_EQ(23, int(GEARMAN_COMMAND_CAN_DO_TIMEOUT));
  73. ASSERT_EQ(24, int(GEARMAN_COMMAND_ALL_YOURS));
  74. ASSERT_EQ(25, int(GEARMAN_COMMAND_WORK_EXCEPTION));
  75. ASSERT_EQ(26, int(GEARMAN_COMMAND_OPTION_REQ));
  76. ASSERT_EQ(27, int(GEARMAN_COMMAND_OPTION_RES));
  77. ASSERT_EQ(28, int(GEARMAN_COMMAND_WORK_DATA));
  78. ASSERT_EQ(29, int(GEARMAN_COMMAND_WORK_WARNING));
  79. ASSERT_EQ(30, int(GEARMAN_COMMAND_GRAB_JOB_UNIQ));
  80. ASSERT_EQ(31, int(GEARMAN_COMMAND_JOB_ASSIGN_UNIQ));
  81. ASSERT_EQ(32, int(GEARMAN_COMMAND_SUBMIT_JOB_HIGH_BG));
  82. ASSERT_EQ(33, int(GEARMAN_COMMAND_SUBMIT_JOB_LOW));
  83. ASSERT_EQ(34, int(GEARMAN_COMMAND_SUBMIT_JOB_LOW_BG));
  84. ASSERT_EQ(35, int(GEARMAN_COMMAND_SUBMIT_JOB_SCHED));
  85. ASSERT_EQ(36, int(GEARMAN_COMMAND_SUBMIT_JOB_EPOCH));
  86. ASSERT_EQ(37, int(GEARMAN_COMMAND_SUBMIT_REDUCE_JOB));
  87. ASSERT_EQ(38, int(GEARMAN_COMMAND_SUBMIT_REDUCE_JOB_BACKGROUND));
  88. ASSERT_EQ(39, int(GEARMAN_COMMAND_GRAB_JOB_ALL));
  89. ASSERT_EQ(40, int(GEARMAN_COMMAND_JOB_ASSIGN_ALL));
  90. return TEST_SUCCESS;
  91. }