Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

erlzmq:version/0 #15

Merged
merged 2 commits into from

3 participants

@gar1t

Useful for sanity checking the library.

@yrashk yrashk commented on the diff
test/erlzmq_test.erl
@@ -58,6 +58,9 @@ reqrep_tcp_test() ->
shutdown_stress_test() ->
?assertMatch(ok, shutdown_stress_loop(10)).
+version_test() ->
+ ?assertEqual({2, 1, 7}, erlzmq:version()).
@yrashk Owner
yrashk added a note

I am not sure this particular test is a good idea, at least while implemented in this particular way

@ianbarber Owner

A greater than test might make sense, could be turned into an int I guess

@yrashk Owner
yrashk added a note

I would rather test the return format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@yrashk yrashk merged commit bd1aaa4 into zeromq:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
13 c_src/erlzmq_nif.c
@@ -105,6 +105,7 @@ NIF(erlzmq_nif_send);
NIF(erlzmq_nif_recv);
NIF(erlzmq_nif_close);
NIF(erlzmq_nif_term);
+NIF(erlzmq_nif_version);
static void * polling_thread(void * handle);
static ERL_NIF_TERM add_active_req(ErlNifEnv* env, erlzmq_socket_t * socket);
@@ -121,7 +122,8 @@ static ErlNifFunc nif_funcs[] =
{"send", 3, erlzmq_nif_send},
{"recv", 2, erlzmq_nif_recv},
{"close", 1, erlzmq_nif_close},
- {"term", 1, erlzmq_nif_term}
+ {"term", 1, erlzmq_nif_term},
+ {"version", 0, erlzmq_nif_version}
};
NIF(erlzmq_nif_context)
@@ -709,6 +711,15 @@ NIF(erlzmq_nif_term)
}
}
+NIF(erlzmq_nif_version)
+{
+ int major, minor, patch;
+ zmq_version(&major, &minor, &patch);
+ return enif_make_tuple3(env, enif_make_int(env, major),
+ enif_make_int(env, minor),
+ enif_make_int(env, patch));
+}
+
static void * polling_thread(void * handle)
{
erlzmq_context_t * context = (erlzmq_context_t *) handle;
View
8 src/erlzmq.erl
@@ -38,7 +38,8 @@
close/1,
close/2,
term/1,
- term/2]).
+ term/2,
+ version/0]).
-export_type([erlzmq_socket/0, erlzmq_context/0]).
%% @equiv context(1)
@@ -291,6 +292,11 @@ term(Context, Timeout) ->
Result
end.
+%% @doc Returns the 0MQ library version.
+%% @end
+-spec version() -> {integer(), integer(), integer()}.
+
+version() -> erlzmq_nif:version().
%% Private
View
6 src/erlzmq_nif.erl
@@ -10,7 +10,8 @@
setsockopt/3,
getsockopt/2,
close/1,
- term/1]).
+ term/1,
+ version/0]).
-on_load(init/0).
@@ -62,3 +63,6 @@ close(_Socket) ->
term(_Context) ->
erlang:nif_error(not_loaded).
+
+version() ->
+ erlang:nif_error(not_loaded).
View
3  test/erlzmq_test.erl
@@ -58,6 +58,9 @@ reqrep_tcp_test() ->
shutdown_stress_test() ->
?assertMatch(ok, shutdown_stress_loop(10)).
+version_test() ->
+ ?assertEqual({2, 1, 7}, erlzmq:version()).
@yrashk Owner
yrashk added a note

I am not sure this particular test is a good idea, at least while implemented in this particular way

@ianbarber Owner

A greater than test might make sense, could be turned into an int I guess

@yrashk Owner
yrashk added a note

I would rather test the return format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
shutdown_stress_loop(0) ->
ok;
shutdown_stress_loop(N) ->
Something went wrong with that request. Please try again.