test_base.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*************************************************************************
  2. * Copyright (C) [2019] by Cambricon, Inc. All rights reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. * THE SOFTWARE.
  19. *************************************************************************/
  20. #ifndef MODULES_TEST_INCLUDE_TEST_BASE_HPP_
  21. #define MODULES_TEST_INCLUDE_TEST_BASE_HPP_
  22. #include <string>
  23. #include <utility>
  24. #define PATH_MAX_LENGTH 1024
  25. std::string GetExePath();
  26. void CheckExePath(const std::string& path);
  27. /**
  28. * @brief Creates a temp file.
  29. * @return Returns temp file informations.
  30. * Return value is a std::pair object, the first value stored temp file fd,
  31. * and the second value stored temp file name.
  32. * @note close(fd), unlink(filename) must be called when the temp file is uesd up.
  33. **/
  34. std::pair<int, std::string> CreateTempFile(const std::string& filename_prefix);
  35. #endif // MODULES_TEST_INCLUDE_TEST_BASE_HPP_