diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2021-06-09 13:15:55 +0200 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2021-06-09 13:15:55 +0200 |
commit | 3a76be69aea97d1195808cc7a90d583d84921e24 (patch) | |
tree | abbf1c1dcae61bac0d379c10d74fb669d0931d7e | |
parent | c1244aa18037355ef36b779edd1eafc060f9495e (diff) |
Add missing Makefile for test
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r-- | src/Makefile | 12 | ||||
-rw-r--r-- | tst/Makefile | 16 | ||||
-rw-r--r-- | tst/tst_thermal.c | 45 |
3 files changed, 42 insertions, 31 deletions
diff --git a/src/Makefile b/src/Makefile index 21ac72d..4870800 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,26 +1,20 @@ # SPDX-License-Identifier: LGPL-2.1+ CC=gcc -CFLAGS=-g -Wall -I/usr/include/libnl3 -Iinclude -fPIC -Wextra -O2 +CFLAGS+=-g -Wall -I/usr/include/libnl3 -I../include -fPIC -Wextra -O2 LDFLAGS=-lnl-genl-3 -lnl-3 -shared -DEPS = include/thermal.h +DEPS = include/libthermal.h OBJS = thermal.o events.o sampling.o commands.o netlink.o LIB=libthermal.so -C_BINS=tst_thermal.c BINS=$(C_BINS:.c=) default: libthermal.so -tests: $(LIB) $(BINS) - %.o: %.c $(DEPS) $(CROSS_COMPILE)$(CC) -c -o $@ $< $(CFLAGS) $(LIB): $(OBJS) $(CROSS_COMPILE)$(CC) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS) -$(BINS): $(C_BINS) - $(CROSS_COMPILE)$(CC) $(CFLAGS) $< -o $@ -lthermal -L. -Wl,-rpath=. - clean: - rm -f $(OBJS) $(LIB) $(BINS) *~ + rm -f $(OBJS) $(LIB) *~ diff --git a/tst/Makefile b/tst/Makefile new file mode 100644 index 0000000..0a68067 --- /dev/null +++ b/tst/Makefile @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: LGPL-2.1+ +CC=gcc +DEPS = ../include/libthermal.h +LIB=../src/libthermal.so +C_BINS=tst_thermal.c +CFLAGS=-Wall -Wno-unused + +BINS=$(C_BINS:.c=) + +tests: $(LIB) $(BINS) + +$(BINS): $(C_BINS) + $(CROSS_COMPILE)$(CC) $(CFLAGS) $< -o $@ -lthermal -L../src -Wl,-rpath=../src -I../include + +clean: + rm -f $(BINS) *~ diff --git a/tst/tst_thermal.c b/tst/tst_thermal.c index ad5b5a1..20e894d 100644 --- a/tst/tst_thermal.c +++ b/tst/tst_thermal.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #include <errno.h> #include <fcntl.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <signal.h> @@ -10,11 +11,11 @@ #include <sys/stat.h> #include <sys/types.h> -#include "thermal.h" +#include "libthermal.h" #define MAX_EVENTS 10 -static int show_trip(struct thermal_trip *tt, __maybe_unused void *arg) +static int show_trip(struct thermal_trip *tt, void *arg) { printf("trip id=%d, type=%d, temp=%d, hyst=%d\n", tt->id, tt->type, tt->temp, tt->hyst); @@ -22,7 +23,7 @@ static int show_trip(struct thermal_trip *tt, __maybe_unused void *arg) return 0; } -static int show_temp(struct thermal_zone *tz, __maybe_unused void *arg) +static int show_temp(struct thermal_zone *tz, void *arg) { thermal_cmd_get_temp(arg, tz); @@ -31,7 +32,7 @@ static int show_temp(struct thermal_zone *tz, __maybe_unused void *arg) return 0; } -static int show_governor(struct thermal_zone *tz, __maybe_unused void *arg) +static int show_governor(struct thermal_zone *tz, void *arg) { thermal_cmd_get_governor(arg, tz); @@ -40,7 +41,7 @@ static int show_governor(struct thermal_zone *tz, __maybe_unused void *arg) return 0; } -static int show_tz(struct thermal_zone *tz, __maybe_unused void *arg) +static int show_tz(struct thermal_zone *tz, void *arg) { printf("thermal zone '%s', id=%d\n", tz->name, tz->id); @@ -53,42 +54,42 @@ static int show_tz(struct thermal_zone *tz, __maybe_unused void *arg) return 0; } -static int tz_create(const char *name, int tz_id, __maybe_unused void *arg) +static int tz_create(const char *name, int tz_id, void *arg) { printf("Thermal zone '%s'/%d created\n", name, tz_id); return 0; } -static int tz_delete(int tz_id, __maybe_unused void *arg) +static int tz_delete(int tz_id, void *arg) { printf("Thermal zone %d deleted\n", tz_id); return 0; } -static int tz_disable(int tz_id, __maybe_unused void *arg) +static int tz_disable(int tz_id, void *arg) { printf("Thermal zone %d disabled\n", tz_id); return 0; } -static int tz_enable(int tz_id, __maybe_unused void *arg) +static int tz_enable(int tz_id, void *arg) { printf("Thermal zone %d enabled\n", tz_id); return 0; } -static int tz_temp(int tz_id, int temp, __maybe_unused void *arg) +static int tz_temp(int tz_id, int temp, void *arg) { printf("Thermal zone %d temperature: %d\n", tz_id, temp); return 0; } -static int trip_high(int tz_id, int trip_id, int temp, __maybe_unused void *arg) +static int trip_high(int tz_id, int trip_id, int temp, void *arg) { printf("Thermal zone %d: trip point %d crossed way up with %d °C\n", tz_id, trip_id, temp); @@ -96,7 +97,7 @@ static int trip_high(int tz_id, int trip_id, int temp, __maybe_unused void *arg) return 0; } -static int trip_low(int tz_id, int trip_id, int temp, __maybe_unused void *arg) +static int trip_low(int tz_id, int trip_id, int temp, void *arg) { printf("Thermal zone %d: trip point %d crossed way down with %d °C\n", tz_id, trip_id, temp); @@ -104,7 +105,7 @@ static int trip_low(int tz_id, int trip_id, int temp, __maybe_unused void *arg) return 0; } -static int trip_add(int tz_id, int trip_id, int type, int temp, int hyst, __maybe_unused void *arg) +static int trip_add(int tz_id, int trip_id, int type, int temp, int hyst, void *arg) { printf("Trip point added %d: id=%d, type=%d, temp=%d, hyst=%d\n", tz_id, trip_id, type, temp, hyst); @@ -112,14 +113,14 @@ static int trip_add(int tz_id, int trip_id, int type, int temp, int hyst, __mayb return 0; } -static int trip_delete(int tz_id, int trip_id, __maybe_unused void *arg) +static int trip_delete(int tz_id, int trip_id, void *arg) { printf("Trip point deleted %d: id=%d\n", tz_id, trip_id); return 0; } -static int trip_change(int tz_id, int trip_id, int type, int temp, int hyst, __maybe_unused void *arg) +static int trip_change(int tz_id, int trip_id, int type, int temp, int hyst, void *arg) { printf("Trip point changed %d: id=%d, type=%d, temp=%d, hyst=%d\n", tz_id, trip_id, type, temp, hyst); @@ -127,7 +128,7 @@ static int trip_change(int tz_id, int trip_id, int type, int temp, int hyst, __m return 0; } -static int cdev_add(const char *name, int cdev_id, int max_state, __maybe_unused void *arg) +static int cdev_add(const char *name, int cdev_id, int max_state, void *arg) { printf("Cooling device '%s'/%d (max state=%d) added", name, cdev_id, max_state); @@ -135,21 +136,21 @@ static int cdev_add(const char *name, int cdev_id, int max_state, __maybe_unused return 0; } -static int cdev_delete(int cdev_id, __maybe_unused void *arg) +static int cdev_delete(int cdev_id, void *arg) { printf("Cooling device %d deleted", cdev_id); return 0; } -static int cdev_update(int cdev_id, int cur_state, __maybe_unused void *arg) +static int cdev_update(int cdev_id, int cur_state, void *arg) { printf("cdev:%d state:%d\n", cdev_id, cur_state); return 0; } -static int gov_change(int tz_id, const char *name, __maybe_unused void *arg) +static int gov_change(int tz_id, const char *name, void *arg) { printf("tz %d, governor=%s\n", tz_id, name); @@ -175,7 +176,7 @@ static struct thermal_ops ops = { static int stop = 0; -static void sighandler(__maybe_unused int sig) +static void sighandler(int sig) { stop = 1; }; @@ -209,10 +210,10 @@ int thermal_sysfs_get_temp_bench(struct thermal_zone *tz) int nr_messages = 0; int nr_secs = 5; unsigned long long sum = 0; - char path[THERMAL_NAME_LENGTH]; + char path[PATH_MAX]; int fd; - snprintf(path, THERMAL_NAME_LENGTH, + snprintf(path, PATH_MAX, "/sys/class/thermal/thermal_zone%d/temp", tz->id); fd = open(path, O_RDONLY); |