Skip to content

Commit

Permalink
Fixed breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Jan 29, 2018
1 parent 7396c9c commit 0300441
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 35 deletions.
18 changes: 9 additions & 9 deletions src/b6b_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ static const struct b6b_file_mode b6b_file_modes[] = {
{"wu", "w", &b6b_wo_file_ops, _IONBF},
{"au", "a", &b6b_wo_file_ops, _IONBF},

{"r+", "r+", &b6b_wo_file_ops, _IOLBF},
{"w+", "w+", &b6b_wo_file_ops, _IOLBF},
{"a+", "a+", &b6b_wo_file_ops, _IOLBF},
{"r+", "r+", &b6b_rw_file_ops, _IOLBF},
{"w+", "w+", &b6b_rw_file_ops, _IOLBF},
{"a+", "a+", &b6b_rw_file_ops, _IOLBF},

{"r+b", "r+", &b6b_wo_file_ops, _IOFBF},
{"w+b", "w+", &b6b_wo_file_ops, _IOFBF},
{"a+b", "a+", &b6b_wo_file_ops, _IOFBF},
{"r+b", "r+", &b6b_rw_file_ops, _IOFBF},
{"w+b", "w+", &b6b_rw_file_ops, _IOFBF},
{"a+b", "a+", &b6b_rw_file_ops, _IOFBF},

{"r+u", "r+", &b6b_wo_file_ops, _IONBF},
{"w+u", "w+", &b6b_wo_file_ops, _IONBF},
{"a+u", "a+", &b6b_wo_file_ops, _IONBF}
{"r+u", "r+", &b6b_rw_file_ops, _IONBF},
{"w+u", "w+", &b6b_rw_file_ops, _IONBF},
{"a+u", "a+", &b6b_rw_file_ops, _IONBF}
};

#define b6b_file_def_mode b6b_file_modes[0]
Expand Down
44 changes: 22 additions & 22 deletions tests/b6b_test_inet_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int main()
struct sockaddr_in dst = {.sin_family = AF_INET},
src = {.sin_family = AF_INET};
char buf[4];
int s1, s2, s3;
int s;

src.sin_port = htons(2923);
src.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
Expand Down Expand Up @@ -86,49 +86,49 @@ int main()
assert(b6b_call_copy(&interp,
"{$inet.server tcp 127.0.0.1 2924}",
33) == B6B_OK);
s1 = socket(AF_INET, SOCK_STREAM, 0);
assert(s1 >= 0);
assert(connect(s1, (const struct sockaddr *)&dst, sizeof(dst)) == 0);
s = socket(AF_INET, SOCK_STREAM, 0);
assert(s >= 0);
assert(connect(s, (const struct sockaddr *)&dst, sizeof(dst)) == 0);
assert(b6b_call_copy(&interp,
"{[$list.index [$_ accept] 0] write abcd}",
40) == B6B_OK);
assert(b6b_as_float(interp.fg->_));
assert(interp.fg->_->f == 4);
assert(recv(s1, buf, sizeof(buf), 0) == sizeof(buf));
assert(recv(s, buf, sizeof(buf), 0) == sizeof(buf));
assert(memcmp(buf, "abcd", 4) == 0);
assert(close(s1) == 0);
assert(close(s) == 0);
b6b_interp_destroy(&interp);

assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
assert(b6b_call_copy(&interp,
"{$inet.server tcp 127.0.0.1 2924}",
33) == B6B_OK);
s1 = socket(AF_INET, SOCK_STREAM, 0);
assert(s1 >= 0);
assert(connect(s1, (const struct sockaddr *)&dst, sizeof(dst)) == 0);
assert(send(s1, "abcd", 4, 0) == 4);
s = socket(AF_INET, SOCK_STREAM, 0);
assert(s >= 0);
assert(connect(s, (const struct sockaddr *)&dst, sizeof(dst)) == 0);
assert(send(s, "abcd", 4, 0) == 4);
assert(b6b_call_copy(&interp,
"{[$list.index [$_ accept] 0] read}",
34) == B6B_OK);
assert(b6b_as_str(interp.fg->_));
assert(interp.fg->_->slen == 4);
assert(strcmp(interp.fg->_->s, "abcd") == 0);
assert(close(s1) == 0);
assert(close(s) == 0);
b6b_interp_destroy(&interp);

assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
assert(b6b_call_copy(&interp,
"{$global a [$inet.server udp 127.0.0.1 2924]}",
45) == B6B_OK);
s1 = socket(AF_INET, SOCK_DGRAM, 0);
assert(s1 >= 0);
assert(sendto(s1,
s = socket(AF_INET, SOCK_DGRAM, 0);
assert(s >= 0);
assert(sendto(s,
"abcd",
4,
0,
(const struct sockaddr *)&dst,
sizeof(dst)) == 4);
assert(sendto(s1,
assert(sendto(s,
"efgh",
4,
0,
Expand All @@ -148,24 +148,24 @@ int main()
assert(b6b_as_float(b6b_list_next(b6b_list_first(interp.fg->_))->o));
assert(b6b_list_next(b6b_list_first(interp.fg->_))->o->f > 0);
assert(b6b_list_next(b6b_list_first(interp.fg->_))->o->f < USHRT_MAX);
assert(close(s1) == 0);
assert(close(s) == 0);
b6b_interp_destroy(&interp);


assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
assert(b6b_call_copy(&interp,
"{$global a [$inet.server udp 127.0.0.1 2924]}",
45) == B6B_OK);
s1 = socket(AF_INET, SOCK_DGRAM, 0);
assert(s1 >= 0);
assert(bind(s1, (const struct sockaddr *)&src, sizeof(src)) == 0);
assert(sendto(s1,
s = socket(AF_INET, SOCK_DGRAM, 0);
assert(s >= 0);
assert(bind(s, (const struct sockaddr *)&src, sizeof(src)) == 0);
assert(sendto(s,
"abcd",
4,
0,
(const struct sockaddr *)&dst,
sizeof(dst)) == 4);
assert(sendto(s1,
assert(sendto(s,
"efgh",
4,
0,
Expand All @@ -184,7 +184,7 @@ int main()
assert(b6b_list_next(b6b_list_first(interp.fg->_)));
assert(b6b_as_float(b6b_list_next(b6b_list_first(interp.fg->_))->o));
assert(b6b_list_next(b6b_list_first(interp.fg->_))->o->f == 2923);
assert(close(s1) == 0);
assert(close(s) == 0);
b6b_interp_destroy(&interp);

return EXIT_SUCCESS;
Expand Down
10 changes: 8 additions & 2 deletions tests/b6b_test_un_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/resource.h>
#ifndef __SANITIZE_ADDRESS__
# include <sys/time.h>
# include <sys/resource.h>
#endif

#include <b6b.h>

int main()
{
struct b6b_interp interp;
#ifndef __SANITIZE_ADDRESS__
struct rlimit rlim;
#endif

assert((unlink("/tmp/x") == 0) || (errno == ENOENT));
assert((unlink("/tmp/abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc") == 0) || (errno == ENOENT));
Expand Down Expand Up @@ -106,13 +110,15 @@ int main()
128) == B6B_OK);
b6b_interp_destroy(&interp);

#ifndef __SANITIZE_ADDRESS__
assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
assert(getrlimit(RLIMIT_NOFILE, &rlim) == 0);
assert(b6b_call_copy(&interp, "{$un.server stream /tmp/x}", 26) == B6B_OK);
rlim.rlim_cur = 1;
assert(setrlimit(RLIMIT_NOFILE, &rlim) == 0);
assert(b6b_call_copy(&interp, "{$un.client stream /tmp/x}", 26) == B6B_ERR);
b6b_interp_destroy(&interp);
#endif

return EXIT_SUCCESS;
}
10 changes: 8 additions & 2 deletions tests/b6b_test_un_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
#include <unistd.h>
#include <sys/un.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/resource.h>
#ifndef __SANITIZE_ADDRESS__
# include <sys/time.h>
# include <sys/resource.h>
#endif

#include <b6b.h>

Expand All @@ -34,7 +36,9 @@ int main()
struct b6b_interp interp;
struct sockaddr_un dst = {.sun_family = AF_UNIX},
src = {.sun_family = AF_UNIX};
#ifndef __SANITIZE_ADDRESS__
struct rlimit rlim;
#endif
char buf[4];
int s1, s2, s3;

Expand Down Expand Up @@ -196,12 +200,14 @@ int main()
assert(interp.fg->_->slen == 0);
b6b_interp_destroy(&interp);

#ifndef __SANITIZE_ADDRESS__
assert(getrlimit(RLIMIT_NOFILE, &rlim) == 0);
rlim.rlim_cur = 1;
assert(setrlimit(RLIMIT_NOFILE, &rlim) == 0);
assert(b6b_interp_new_argv(&interp, 0, NULL, B6B_OPT_TRACE));
assert(b6b_call_copy(&interp, "{$un.server stream /tmp/x}", 26) == B6B_ERR);
b6b_interp_destroy(&interp);
#endif

return EXIT_SUCCESS;
}

0 comments on commit 0300441

Please sign in to comment.