Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115116203
D30671.id90597.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D30671.id90597.diff
View Options
diff --git a/tests/sys/netgraph/util.h b/tests/sys/netgraph/util.h
--- a/tests/sys/netgraph/util.h
+++ b/tests/sys/netgraph/util.h
@@ -34,21 +34,47 @@
#include <netgraph.h>
-void ng_connect (char const *path1, char const *hook1,
- char const *path2, char const *hook2);
-void ng_mkpeer (char const *path1, char const *hook1,
- char const *type, char const *hook2);
-void ng_shutdown(char const *path);
-void ng_rmhook (char const *path, char const *hook);
-void ng_name (char const *path, char const *name);
+void _ng_connect (char const *path1, char const *hook1,
+ char const *path2, char const *hook2,
+ char const *file, size_t line);
+#define ng_connect(p1,h1,p2,h2) \
+ _ng_connect(p1,h1,p2,h2,__FILE__,__LINE__)
+
+void _ng_mkpeer (char const *path1, char const *hook1,
+ char const *type, char const *hook2,
+ char const *file, size_t line);
+#define ng_mkpeer(p1,h1,t,h2) \
+ _ng_mkpeer(p1,h1,t,h2,__FILE__,__LINE__)
+
+void _ng_shutdown(char const *path,
+ char const *file, size_t line);
+#define ng_shutdown(p) \
+ _ng_shutdown(p,__FILE__,__LINE__)
+
+void _ng_rmhook (char const *path, char const *hook,
+ char const *file, size_t line);
+#define ng_rmhook(p,h) \
+ _ng_rmhook(p,h,__FILE__,__LINE__)
+
+void _ng_name (char const *path, char const *name,
+ char const *file, size_t line);
+#define ng_name(p,n) \
+ _ng_name(p,n,__FILE__,__LINE__)
+
typedef void (*ng_data_handler_t)(void *, size_t, void *ctx);
void ng_register_data(char const *hook, ng_data_handler_t proc);
-void ng_send_data(char const *hook, void const *, size_t);
+void _ng_send_data(char const *hook, void const *, size_t,
+ char const *file, size_t line);
+#define ng_send_data(h,d,l) \
+ _ng_send_data(h,d,l,__FILE__,__LINE__)
typedef void (*ng_msg_handler_t)(char const *, struct ng_mesg *, void *);
void ng_register_msg(ng_msg_handler_t proc);
-int ng_send_msg(char const *path, char const *msg);
+int _ng_send_msg(char const *path, char const *msg,
+ char const *file, size_t line);
+#define ng_send_msg(p,m) \
+ _ng_send_msg(p,m,__FILE__,__LINE__)
int ng_handle_event (unsigned int ms, void *ctx);
void ng_handle_events(unsigned int ms, void *ctx);
@@ -56,4 +82,6 @@
typedef enum { FAIL, PASS } ng_error_t;
ng_error_t ng_errors(ng_error_t);
-void ng_init(void);
+void _ng_init(char const *file, size_t line);
+#define ng_init() \
+ _ng_init(__FILE__,__LINE__)
diff --git a/tests/sys/netgraph/util.c b/tests/sys/netgraph/util.c
--- a/tests/sys/netgraph/util.c
+++ b/tests/sys/netgraph/util.c
@@ -45,11 +45,13 @@
static int cs = -1, ds = -1;
static ng_error_t error_handling = FAIL;
-#define CHECK(r, x) do { \
- if (error_handling == FAIL) \
- ATF_REQUIRE(x); \
- else if(!(x)) \
- return r; \
+#define CHECK(r, x) do { \
+ if (!(x)) { \
+ if (error_handling == PASS) \
+ return r; \
+ atf_tc_fail_requirement(file, line, "%s (%s)", \
+ #x " not met", strerror(errno));\
+ } \
} while(0)
struct data_handler {
@@ -64,8 +66,9 @@
static void handle_msg(void *ctx);
void
-ng_connect(char const *path1, char const *hook1,
- char const *path2, char const *hook2)
+_ng_connect(char const *path1, char const *hook1,
+ char const *path2, char const *hook2,
+ char const *file, size_t line)
{
struct ngm_connect c;
@@ -79,8 +82,9 @@
}
void
-ng_mkpeer(char const *path1, char const *hook1,
- char const *type, char const *hook2)
+_ng_mkpeer(char const *path1, char const *hook1,
+ char const *type, char const *hook2,
+ char const *file, size_t line)
{
struct ngm_mkpeer p;
@@ -94,7 +98,8 @@
}
void
-ng_rmhook(char const *path, char const *hook)
+_ng_rmhook(char const *path, char const *hook,
+ char const *file, size_t line)
{
struct ngm_rmhook h;
@@ -106,7 +111,8 @@
}
void
-ng_name(char const *path, char const *name)
+_ng_name(char const *path, char const *name,
+ char const *file, size_t line)
{
struct ngm_name n;
@@ -118,7 +124,8 @@
}
void
-ng_shutdown(char const *path)
+_ng_shutdown(char const *path,
+ char const *file, size_t line)
{
CHECK(, -1 != NgSendMsg(cs, path,
NGM_GENERIC_COOKIE, NGM_SHUTDOWN,
@@ -137,8 +144,9 @@
}
void
-ng_send_data(char const *hook,
- void const *data, size_t len)
+_ng_send_data(char const *hook,
+ void const *data, size_t len,
+ char const *file, size_t line)
{
CHECK(, -1 != NgSendData(ds, hook, data, len));
}
@@ -213,7 +221,8 @@
}
int
-ng_send_msg(char const *path, char const *msg)
+_ng_send_msg(char const *path, char const *msg,
+ char const *file, size_t line)
{
int res;
@@ -231,10 +240,10 @@
}
void
-ng_init(void) {
+_ng_init(char const *file, size_t line) {
if (cs >= 0) /* prevent reinit */
return;
- ATF_REQUIRE(0 == NgMkSockNode(NULL, &cs, &ds));
+ CHECK(, 0 == NgMkSockNode(NULL, &cs, &ds));
NgSetDebug(3);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 21, 2:57 PM (10 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17674575
Default Alt Text
D30671.id90597.diff (4 KB)
Attached To
Mode
D30671: tests/netgraph: Attribute errors to the caller
Attached
Detach File
Event Timeline
Log In to Comment