test_utils.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include <string.h>
  15. #include "unity.h"
  16. #include "test_utils.h"
  17. #include "rom/ets_sys.h"
  18. #include "rom/uart.h"
  19. const esp_partition_t *get_test_data_partition()
  20. {
  21. /* This finds "flash_test" partition defined in partition_table_unit_test_app.csv */
  22. const esp_partition_t *result = esp_partition_find_first(ESP_PARTITION_TYPE_DATA,
  23. ESP_PARTITION_SUBTYPE_ANY, "flash_test");
  24. TEST_ASSERT_NOT_NULL(result); /* means partition table set wrong */
  25. return result;
  26. }
  27. // wait user to send "Enter" key
  28. static void wait_user_control()
  29. {
  30. char sign[5] = {0};
  31. while(strlen(sign) == 0)
  32. {
  33. /* Flush anything already in the RX buffer */
  34. while(uart_rx_one_char((uint8_t *) sign) == OK) {
  35. }
  36. /* Read line */
  37. UartRxString((uint8_t*) sign, sizeof(sign) - 1);
  38. }
  39. }
  40. // signal functions, used for sync between unity DUTs for multiple devices cases
  41. void unity_wait_for_signal(const char* signal_name)
  42. {
  43. printf("Waiting for signal: [%s]!\n"
  44. "Please press \"Enter\" key to once any board send this signal.\n", signal_name);
  45. wait_user_control();
  46. }
  47. void unity_send_signal(const char* signal_name)
  48. {
  49. printf("Send signal: [%s]!\n", signal_name);
  50. }