2013-03-07 08:37:42 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the libsigrok project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Uwe Hermann <uwe@hermann-uwe.de>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-10-20 07:57:25 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2013-03-07 08:37:42 +00:00
|
|
|
*/
|
|
|
|
|
2015-09-13 16:22:17 +00:00
|
|
|
#include <config.h>
|
2013-03-07 08:37:42 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <check.h>
|
2015-08-13 00:06:41 +00:00
|
|
|
#include <libsigrok/libsigrok.h>
|
2013-03-07 08:37:42 +00:00
|
|
|
#include "lib.h"
|
|
|
|
|
|
|
|
/* Check whether at least one driver is available. */
|
|
|
|
START_TEST(test_driver_available)
|
|
|
|
{
|
|
|
|
struct sr_dev_driver **drivers;
|
|
|
|
|
2015-04-04 18:57:22 +00:00
|
|
|
drivers = sr_driver_list(srtest_ctx);
|
2013-03-07 08:37:42 +00:00
|
|
|
fail_unless(drivers != NULL, "No drivers found.");
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
/* Check whether initializing all drivers works. */
|
|
|
|
START_TEST(test_driver_init_all)
|
|
|
|
{
|
2014-08-11 11:20:50 +00:00
|
|
|
srtest_driver_init_all(srtest_ctx);
|
2013-03-07 08:37:42 +00:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check whether setting a samplerate works.
|
|
|
|
*
|
|
|
|
* Additionally, this also checks whether SR_CONF_SAMPLERATE can be both
|
|
|
|
* set and read back properly.
|
|
|
|
*/
|
2013-04-27 17:06:27 +00:00
|
|
|
#if 0
|
2013-03-07 08:37:42 +00:00
|
|
|
START_TEST(test_config_get_set_samplerate)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Note: This currently only works for the demo driver.
|
|
|
|
* For other drivers, a scan is needed and the respective
|
|
|
|
* hardware must be attached to the host running the testsuite.
|
|
|
|
*/
|
|
|
|
srtest_check_samplerate(sr_ctx, "demo", SR_KHZ(19));
|
|
|
|
}
|
|
|
|
END_TEST
|
2013-04-27 17:06:27 +00:00
|
|
|
#endif
|
2013-03-07 08:37:42 +00:00
|
|
|
|
|
|
|
Suite *suite_driver_all(void)
|
|
|
|
{
|
|
|
|
Suite *s;
|
|
|
|
TCase *tc;
|
|
|
|
|
|
|
|
s = suite_create("driver-all");
|
|
|
|
|
|
|
|
tc = tcase_create("config");
|
2014-08-11 11:20:50 +00:00
|
|
|
tcase_add_checked_fixture(tc, srtest_setup, srtest_teardown);
|
2013-03-07 08:37:42 +00:00
|
|
|
tcase_add_test(tc, test_driver_available);
|
|
|
|
tcase_add_test(tc, test_driver_init_all);
|
2013-04-27 17:06:27 +00:00
|
|
|
// TODO: Currently broken.
|
|
|
|
// tcase_add_test(tc, test_config_get_set_samplerate);
|
2013-03-07 08:37:42 +00:00
|
|
|
suite_add_tcase(s, tc);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|