main: Add helper for mocking device node
This commit is contained in:
@@ -25,6 +25,7 @@ sources = [
|
||||
'accel-mount-matrix.c',
|
||||
'accel-scale.c',
|
||||
'accel-attributes.c',
|
||||
'utils.c',
|
||||
resources,
|
||||
]
|
||||
|
||||
|
21
src/utils.c
Normal file
21
src/utils.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Bastien Nocera <hadess@hadess.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 3 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
char *
|
||||
get_device_file (GUdevDevice *device)
|
||||
{
|
||||
if (!IS_TEST)
|
||||
return g_udev_device_get_device_file (device);
|
||||
|
||||
return g_build_filename (g_getenv ("UMOCKDEV_DIR"),
|
||||
"iio-dev-data.bin",
|
||||
NULL);
|
||||
}
|
@@ -10,5 +10,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <glib.h>
|
||||
#include <gudev/gudev.h>
|
||||
|
||||
#define IS_TEST (g_getenv ("UMOCKDEV_DIR") != NULL)
|
||||
|
||||
char *get_device_file (GUdevDevice *device);
|
||||
|
Reference in New Issue
Block a user