1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-28 13:55:08 +03:00
Files
libgpiod/tests/unit/tests-misc.c
Bartosz Golaszewski 8c46433f8a tests: add misc test cases
Add test cases for err handling and gpiod_version_string().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-03-02 10:37:38 +01:00

43 lines
1.1 KiB
C

/*
* Misc test cases for libgpiod.
*
* Copyright (C) 2017 Bartosz Golaszewski <bartekgola@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2.1 of the GNU Lesser General Public License
* as published by the Free Software Foundation.
*/
#include "gpiod-unit.h"
#include <errno.h>
static void version_string(void)
{
/* Check that gpiod_version_string() returns an actual string. */
GU_ASSERT_NOT_NULL(gpiod_version_string());
GU_ASSERT(strlen(gpiod_version_string()) > 0);
}
GU_DEFINE_TEST(version_string,
"gpiod_version_string()",
GU_LINES_UNNAMED, { 1 });
static void error_handling(void)
{
struct gpiod_chip *chip;
int err;
chip = gpiod_chip_open("/dev/nonexistent_gpiochip");
GU_ASSERT_NULL(chip);
err = gpiod_errno();
GU_ASSERT_EQ(err, ENOENT);
GU_ASSERT_NOT_NULL(gpiod_strerror(err));
GU_ASSERT(strlen(gpiod_strerror(err)) > 0);
GU_ASSERT_STR_EQ(gpiod_strerror(err), gpiod_last_strerror());
}
GU_DEFINE_TEST(error_handling,
"error handling",
GU_LINES_UNNAMED, { 1 });