diff options
Diffstat (limited to 'host/tests')
| -rw-r--r-- | host/tests/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | host/tests/error_c_test.cpp | 18 | ||||
| -rw-r--r-- | host/tests/string_vector_c_test.c (renamed from host/tests/device_addrs_c_test.c) | 38 | 
3 files changed, 31 insertions, 29 deletions
diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt index ac0486f2e..e41d61bde 100644 --- a/host/tests/CMakeLists.txt +++ b/host/tests/CMakeLists.txt @@ -1,5 +1,5 @@  # -# Copyright 2010-2011 Ettus Research LLC +# Copyright 2010-2015 Ettus Research LLC  #  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU General Public License as published by @@ -55,11 +55,11 @@ SET(UHD_TEST_LIBRARY_DIRS ${Boost_LIBRARY_DIRS})  IF(ENABLE_C_API)      LIST(APPEND test_sources -	device_addrs_c_test.c          eeprom_c_test.c          error_c_test.cpp          ranges_c_test.c          sensors_c_test.c +        string_vector_c_test.c          subdev_spec_c_test.c      )  ENDIF(ENABLE_C_API) diff --git a/host/tests/error_c_test.cpp b/host/tests/error_c_test.cpp index bb9454678..8eb90f3d4 100644 --- a/host/tests/error_c_test.cpp +++ b/host/tests/error_c_test.cpp @@ -82,10 +82,11 @@ static const uhd::dict<std::string, std::string> pretty_exception_names =      uhd::cpp_exception_type cpp_exception_type ## _foo(expected_msg); \      error_code = throw_uhd_exception<uhd::cpp_exception_type>(&handle, &cpp_exception_type ## _foo); \      BOOST_CHECK_EQUAL(error_code, c_error_code); \ -    BOOST_CHECK_EQUAL(handle.last_error, \ -                      str(boost::format("%s: %s") \ -                          % pretty_exception_names.get(BOOST_STRINGIZE(cpp_exception_type)) \ -                          % expected_msg)); +    expected_msg = str(boost::format("%s: %s") \ +                       % pretty_exception_names.get(BOOST_STRINGIZE(cpp_exception_type)) \ +                       % expected_msg); \ +    BOOST_CHECK_EQUAL(handle.last_error, expected_msg); \ +    BOOST_CHECK_EQUAL(get_c_global_error_string(), expected_msg);  // uhd::usb_error has a different constructor  #define UHD_TEST_CHECK_USB_ERROR_CODE() \ @@ -93,10 +94,11 @@ static const uhd::dict<std::string, std::string> pretty_exception_names =      uhd::usb_error usb_error_foo(1, expected_msg); \      error_code = throw_uhd_exception<uhd::usb_error>(&handle, &usb_error_foo); \      BOOST_CHECK_EQUAL(error_code, UHD_ERROR_USB); \ -    BOOST_CHECK_EQUAL(handle.last_error, \ -                      str(boost::format("%s: %s") \ -                          % pretty_exception_names.get("usb_error") \ -                          % expected_msg)); +    expected_msg = str(boost::format("%s: %s") \ +                       % pretty_exception_names.get("usb_error") \ +                       % expected_msg); \ +    BOOST_CHECK_EQUAL(handle.last_error, expected_msg); \ +    BOOST_CHECK_EQUAL(get_c_global_error_string(), expected_msg);  BOOST_AUTO_TEST_CASE(test_uhd_exception){      dummy_handle_t handle; diff --git a/host/tests/device_addrs_c_test.c b/host/tests/string_vector_c_test.c index e84068a75..fe055fd91 100644 --- a/host/tests/device_addrs_c_test.c +++ b/host/tests/string_vector_c_test.c @@ -34,53 +34,53 @@ int main(){      // Variables      int return_code; -    uhd_device_addrs_handle device_addrs; +    uhd_string_vector_handle string_vector;      size_t size;      char str_buffer[BUFFER_SIZE];      return_code = EXIT_SUCCESS; -    // Create device_addrs +    // Create string_vector      UHD_TEST_EXECUTE_OR_GOTO(end_of_test, -        uhd_device_addrs_make(&device_addrs) +        uhd_string_vector_make(&string_vector)      )      // Add values -    UHD_TEST_EXECUTE_OR_GOTO(free_device_addrs, -	uhd_device_addrs_push_back(device_addrs, "key1=value1,key2=value2") +    UHD_TEST_EXECUTE_OR_GOTO(free_string_vector, +        uhd_string_vector_push_back(&string_vector, "foo")      ) -    UHD_TEST_EXECUTE_OR_GOTO(free_device_addrs, -	uhd_device_addrs_push_back(device_addrs, "key3=value3,key4=value4") +    UHD_TEST_EXECUTE_OR_GOTO(free_string_vector, +        uhd_string_vector_push_back(&string_vector, "bar")      )      // Check size -    UHD_TEST_EXECUTE_OR_GOTO(free_device_addrs, -	uhd_device_addrs_size(device_addrs, &size) +    UHD_TEST_EXECUTE_OR_GOTO(free_string_vector, +        uhd_string_vector_size(string_vector, &size)      )      if(size != 2){ -	return_code = EXIT_FAILURE; +        return_code = EXIT_FAILURE;          fprintf(stderr, "%s:%d: Invalid size: %lu vs. 2",                          __FILE__, __LINE__,size); -        goto free_device_addrs; +        goto free_string_vector;      }      // Make sure we get right value -    UHD_TEST_EXECUTE_OR_GOTO(free_device_addrs, -	uhd_device_addrs_at(device_addrs, 1, str_buffer, BUFFER_SIZE) +    UHD_TEST_EXECUTE_OR_GOTO(free_string_vector, +        uhd_string_vector_at(string_vector, 1, str_buffer, BUFFER_SIZE)      ) -    if(strcmp(str_buffer, "key3=value3,key4=value4")){ +    if(strcmp(str_buffer, "bar")){          return_code = EXIT_FAILURE;          fprintf(stderr, "%s:%d: Mismatched daughterboard serial: \"%s\" vs. \"key3=value3,key4=value4\"\n",                          __FILE__, __LINE__,                          str_buffer);      } -    free_device_addrs: +    free_string_vector:          if(return_code){ -	    uhd_device_addrs_last_error(device_addrs, str_buffer, BUFFER_SIZE); -            fprintf(stderr, "device_addrs error: %s\n", str_buffer); -	} -	uhd_device_addrs_free(&device_addrs); +            uhd_string_vector_last_error(string_vector, str_buffer, BUFFER_SIZE); +            fprintf(stderr, "string_vector error: %s\n", str_buffer); +        } +        uhd_string_vector_free(&string_vector);      end_of_test:          if(!return_code){  | 
