Permalink
Browse files

Merge pull request #23 from steveschnepp/t

 Create some very simple test subdir
  • Loading branch information...
2 parents d665fca + c8e5ff4 commit 048b7457052ac94fe4d4e58c5c71133379e51bb5 @steveschnepp steveschnepp committed Jul 9, 2015
Showing with 85 additions and 8 deletions.
  1. +1 −1 Makefile.am
  2. +1 −1 configure.ac
  3. +4 −0 t/.gitignore
  4. +5 −6 t/{env → Makefile.am}
  5. +9 −0 t/common.c
  6. +7 −0 t/common.h
  7. +40 −0 t/nb_env.c
  8. +18 −0 t/ok_plugin.c
View
@@ -12,7 +12,7 @@ pkglibexecdir = $(libexecdir)/$(PACKAGE)
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = src/node src/plugins
+SUBDIRS = src/node src/plugins t
dist_doc_DATA = gpl-2.0.txt gpl-3.0.txt
EXTRA_DIST = README.md
View
@@ -23,5 +23,5 @@ AC_PROG_LN_S
AC_FUNC_FORK
CC_CHECK_CFLAGS_APPEND([-Wall -Wextra -Werror -pedantic -Wno-format])
-AC_CONFIG_FILES([Makefile src/node/Makefile src/plugins/Makefile])
+AC_CONFIG_FILES([Makefile src/node/Makefile src/plugins/Makefile t/Makefile])
AC_OUTPUT
View
@@ -0,0 +1,4 @@
+/Makefile
+/Makefile.in
+/nb_env
+/ok_plugin
View
11 t/env → t/Makefile.am 100755 → 100644
@@ -1,13 +1,12 @@
-#! /bin/sh
-#
-# Copyright (C) 2013 Steve Schnepp <steve.schnepp@pwkf.org> - All rights reserved.
+# Copyright (C) 2014 Steve Schnepp <steve.schnepp@pwkf.org> - All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2 or v.3.
#
-echo "ENV:"
-export
+include $(top_srcdir)/common.am
-echo "ARGS:" "$@"
+sbin_PROGRAMS = ok_plugin nb_env
+ok_plugin_SOURCES = ok_plugin.c common.c
+nb_env_SOURCES = nb_env.c common.c
View
@@ -0,0 +1,9 @@
+/* Simmle plugin framework */
+#include <string.h>
+
+#include "common.h"
+
+int main(int argc, const char* argv[]) {
+ int is_config = (argc == 2) && (strcmp(argv[1], "config") == 0);
+ return is_config ? emit_config() : emit_fetch();
+}
View
@@ -0,0 +1,7 @@
+/* This is the forward API of all test plugins */
+
+int emit_config();
+int emit_fetch();
+
+/* This is the common main function */
+int main(int argc, const char* argv[]);
View
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <unistd.h>
+
+#include "common.h"
+
+extern char **environ;
+
+int count_env_nb() {
+ int env_nb = 0;
+ char **cur_environ = environ;
+ while (*cur_environ) {
+ env_nb ++;
+ cur_environ ++;
+ }
+
+ return env_nb;
+}
+
+int emit_config() {
+ printf("graph_title " __FILE__ "\n");
+ printf("env_nb.label Number of env vars\n");
+
+ return 0;
+}
+
+int emit_fetch() {
+ char **cur_environ = environ;
+
+ printf("env_nb.value %d\n", count_env_nb());
+ printf("env_nb.ext_info ");
+
+ while (*cur_environ) {
+ printf("{%s},", *cur_environ);
+ cur_environ ++;
+ }
+
+ printf("\n");
+
+ return 0;
+}
View
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+#include "common.h"
+
+int emit_config() {
+ printf("graph_title " __FILE__ "\n");
+ printf("first_f.label This is the first field\n");
+ printf("second_f.label This is the second field\n");
+
+ return 0;
+}
+
+int emit_fetch() {
+ printf("first_f.value %f\n", 1234.567);
+ printf("second_f.value %f\n", -2345.678);
+
+ return 0;
+}

0 comments on commit 048b745

Please sign in to comment.