expect.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include "expect.h"
  19. #include "hdfs.h"
  20. #include <inttypes.h>
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. int expectFileStats(hdfsFile file,
  25. uint64_t expectedTotalBytesRead,
  26. uint64_t expectedTotalLocalBytesRead,
  27. uint64_t expectedTotalShortCircuitBytesRead,
  28. uint64_t expectedTotalZeroCopyBytesRead)
  29. {
  30. struct hdfsReadStatistics *stats = NULL;
  31. EXPECT_ZERO(hdfsFileGetReadStatistics(file, &stats));
  32. fprintf(stderr, "expectFileStats(expectedTotalBytesRead=%"PRId64", "
  33. "expectedTotalLocalBytesRead=%"PRId64", "
  34. "expectedTotalShortCircuitBytesRead=%"PRId64", "
  35. "expectedTotalZeroCopyBytesRead=%"PRId64", "
  36. "totalBytesRead=%"PRId64", "
  37. "totalLocalBytesRead=%"PRId64", "
  38. "totalShortCircuitBytesRead=%"PRId64", "
  39. "totalZeroCopyBytesRead=%"PRId64")\n",
  40. expectedTotalBytesRead,
  41. expectedTotalLocalBytesRead,
  42. expectedTotalShortCircuitBytesRead,
  43. expectedTotalZeroCopyBytesRead,
  44. stats->totalBytesRead,
  45. stats->totalLocalBytesRead,
  46. stats->totalShortCircuitBytesRead,
  47. stats->totalZeroCopyBytesRead);
  48. if (expectedTotalBytesRead != UINT64_MAX) {
  49. EXPECT_UINT64_EQ(expectedTotalBytesRead, stats->totalBytesRead);
  50. }
  51. if (expectedTotalLocalBytesRead != UINT64_MAX) {
  52. EXPECT_UINT64_EQ(expectedTotalLocalBytesRead,
  53. stats->totalLocalBytesRead);
  54. }
  55. if (expectedTotalShortCircuitBytesRead != UINT64_MAX) {
  56. EXPECT_UINT64_EQ(expectedTotalShortCircuitBytesRead,
  57. stats->totalShortCircuitBytesRead);
  58. }
  59. if (expectedTotalZeroCopyBytesRead != UINT64_MAX) {
  60. EXPECT_UINT64_EQ(expectedTotalZeroCopyBytesRead,
  61. stats->totalZeroCopyBytesRead);
  62. }
  63. hdfsFileFreeReadStatistics(stats);
  64. return 0;
  65. }