testtemp.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "testutil.h"
  17. #include "fspr_file_io.h"
  18. #include "fspr_strings.h"
  19. static void test_temp_dir(abts_case *tc, void *data)
  20. {
  21. const char *tempdir = NULL;
  22. fspr_status_t rv;
  23. rv = fspr_temp_dir_get(&tempdir, p);
  24. APR_ASSERT_SUCCESS(tc, "Error finding Temporary Directory", rv);
  25. ABTS_PTR_NOTNULL(tc, tempdir);
  26. }
  27. static void test_mktemp(abts_case *tc, void *data)
  28. {
  29. fspr_file_t *f = NULL;
  30. const char *tempdir = NULL;
  31. char *filetemplate;
  32. fspr_status_t rv;
  33. rv = fspr_temp_dir_get(&tempdir, p);
  34. APR_ASSERT_SUCCESS(tc, "Error finding Temporary Directory", rv);
  35. filetemplate = fspr_pstrcat(p, tempdir, "/tempfileXXXXXX", NULL);
  36. rv = fspr_file_mktemp(&f, filetemplate, 0, p);
  37. APR_ASSERT_SUCCESS(tc, "Error opening Temporary file", rv);
  38. }
  39. abts_suite *testtemp(abts_suite *suite)
  40. {
  41. suite = ADD_SUITE(suite)
  42. abts_run_test(suite, test_temp_dir, NULL);
  43. abts_run_test(suite, test_mktemp, NULL);
  44. return suite;
  45. }