summaryrefslogtreecommitdiff
path: root/nix-test/src
diff options
context:
space:
mode:
Diffstat (limited to 'nix-test/src')
-rw-r--r--nix-test/src/const.c268
-rw-r--r--nix-test/src/lib.rs61
-rw-r--r--nix-test/src/sizes.c32
3 files changed, 0 insertions, 361 deletions
diff --git a/nix-test/src/const.c b/nix-test/src/const.c
deleted file mode 100644
index bb70fc92..00000000
--- a/nix-test/src/const.c
+++ /dev/null
@@ -1,268 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/ip6.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-
-#define GET_CONST(CONST) \
- do { \
- if (0 == strcmp(err, #CONST)) { \
- return CONST; \
- } \
- } while (0)
-
-int
-get_int_const(const char* err) {
-
- /*
- *
- * ===== ERRNO =====
- *
- */
-
- GET_CONST(EPERM);
- GET_CONST(ENOENT);
- GET_CONST(ESRCH);
- GET_CONST(EINTR);
- GET_CONST(EIO);
- GET_CONST(ENXIO);
- GET_CONST(E2BIG);
- GET_CONST(ENOEXEC);
- GET_CONST(EBADF);
- GET_CONST(ECHILD);
- GET_CONST(EAGAIN);
- GET_CONST(ENOMEM);
- GET_CONST(EACCES);
- GET_CONST(EFAULT);
- GET_CONST(ENOTBLK);
- GET_CONST(EBUSY);
- GET_CONST(EEXIST);
- GET_CONST(EXDEV);
- GET_CONST(ENODEV);
- GET_CONST(ENOTDIR);
- GET_CONST(EISDIR);
- GET_CONST(EINVAL);
- GET_CONST(ENFILE);
- GET_CONST(EMFILE);
- GET_CONST(ENOTTY);
- GET_CONST(ETXTBSY);
- GET_CONST(EFBIG);
- GET_CONST(ENOSPC);
- GET_CONST(ESPIPE);
- GET_CONST(EROFS);
- GET_CONST(EMLINK);
- GET_CONST(EPIPE);
- GET_CONST(EDOM);
- GET_CONST(ERANGE);
- GET_CONST(EDEADLK);
- GET_CONST(ENAMETOOLONG);
- GET_CONST(ENOLCK);
- GET_CONST(ENOSYS);
- GET_CONST(ENOTEMPTY);
- GET_CONST(ELOOP);
- GET_CONST(ENOMSG);
- GET_CONST(EIDRM);
- GET_CONST(EINPROGRESS);
- GET_CONST(EALREADY);
- GET_CONST(ENOTSOCK);
- GET_CONST(EDESTADDRREQ);
- GET_CONST(EMSGSIZE);
- GET_CONST(EPROTOTYPE);
- GET_CONST(ENOPROTOOPT);
- GET_CONST(EPROTONOSUPPORT);
- GET_CONST(ESOCKTNOSUPPORT);
- GET_CONST(EPFNOSUPPORT);
- GET_CONST(EAFNOSUPPORT);
- GET_CONST(EADDRINUSE);
- GET_CONST(EADDRNOTAVAIL);
- GET_CONST(ENETDOWN);
- GET_CONST(ENETUNREACH);
- GET_CONST(ENETRESET);
- GET_CONST(ECONNABORTED);
- GET_CONST(ECONNRESET);
- GET_CONST(ENOBUFS);
- GET_CONST(EISCONN);
- GET_CONST(ENOTCONN);
- GET_CONST(ESHUTDOWN);
- GET_CONST(ETOOMANYREFS);
- GET_CONST(ETIMEDOUT);
- GET_CONST(ECONNREFUSED);
- GET_CONST(EHOSTDOWN);
- GET_CONST(EHOSTUNREACH);
-
-#ifdef LINUX
- GET_CONST(ECHRNG);
- GET_CONST(EL2NSYNC);
- GET_CONST(EL3HLT);
- GET_CONST(EL3RST);
- GET_CONST(ELNRNG);
- GET_CONST(EUNATCH);
- GET_CONST(ENOCSI);
- GET_CONST(EL2HLT);
- GET_CONST(EBADE);
- GET_CONST(EBADR);
- GET_CONST(EXFULL);
- GET_CONST(ENOANO);
- GET_CONST(EBADRQC);
- GET_CONST(EBADSLT);
- GET_CONST(EBFONT);
- GET_CONST(ENOSTR);
- GET_CONST(ENODATA);
- GET_CONST(ETIME);
- GET_CONST(ENOSR);
- GET_CONST(ENONET);
- GET_CONST(ENOPKG);
- GET_CONST(EREMOTE);
- GET_CONST(ENOLINK);
- GET_CONST(EADV);
- GET_CONST(ESRMNT);
- GET_CONST(ECOMM);
- GET_CONST(EPROTO);
- GET_CONST(EMULTIHOP);
- GET_CONST(EDOTDOT);
- GET_CONST(EBADMSG);
- GET_CONST(EOVERFLOW);
- GET_CONST(ENOTUNIQ);
- GET_CONST(EBADFD);
- GET_CONST(EREMCHG);
- GET_CONST(ELIBACC);
- GET_CONST(ELIBBAD);
- GET_CONST(ELIBSCN);
- GET_CONST(ELIBMAX);
- GET_CONST(ELIBEXEC);
- GET_CONST(EILSEQ);
- GET_CONST(ERESTART);
- GET_CONST(ESTRPIPE);
- GET_CONST(EUSERS);
- GET_CONST(EOPNOTSUPP);
- GET_CONST(ESTALE);
- GET_CONST(EUCLEAN);
- GET_CONST(ENOTNAM);
- GET_CONST(ENAVAIL);
- GET_CONST(EISNAM);
- GET_CONST(EREMOTEIO);
- GET_CONST(EDQUOT);
- GET_CONST(ENOMEDIUM);
- GET_CONST(EMEDIUMTYPE);
- GET_CONST(ECANCELED);
- GET_CONST(ENOKEY);
- GET_CONST(EKEYEXPIRED);
- GET_CONST(EKEYREVOKED);
- GET_CONST(EKEYREJECTED);
- GET_CONST(EOWNERDEAD);
- GET_CONST(ENOTRECOVERABLE);
-#ifndef __ANDROID__
- GET_CONST(ERFKILL);
- // GET_CONST(EHWPOISON);
-#endif
-#endif
-#if defined(DARWIN) || defined(__FreeBSD__)
- GET_CONST(ENEEDAUTH);
- GET_CONST(EOVERFLOW);
- GET_CONST(EILSEQ);
- GET_CONST(ENOATTR);
- GET_CONST(EBADMSG);
- GET_CONST(EPROTO);
- GET_CONST(ENOTRECOVERABLE);
- GET_CONST(EOWNERDEAD);
- GET_CONST(ENOTSUP);
- GET_CONST(EPROCLIM);
- GET_CONST(EUSERS);
- GET_CONST(EDQUOT);
- GET_CONST(ESTALE);
- GET_CONST(EREMOTE);
- GET_CONST(EBADRPC);
- GET_CONST(ERPCMISMATCH);
- GET_CONST(EPROGUNAVAIL);
- GET_CONST(EPROGMISMATCH);
- GET_CONST(EPROCUNAVAIL);
- GET_CONST(EFTYPE);
- GET_CONST(EAUTH);
- GET_CONST(ECANCELED);
-#endif
-
-#if defined(__DragonFly__)
- GET_CONST(ENEEDAUTH);
- GET_CONST(EOVERFLOW);
- GET_CONST(EILSEQ);
- GET_CONST(ENOATTR);
- GET_CONST(EBADMSG);
- GET_CONST(EPROTO);
- GET_CONST(ENOTSUP);
- GET_CONST(EPROCLIM);
- GET_CONST(EUSERS);
- GET_CONST(EDQUOT);
- GET_CONST(ESTALE);
- GET_CONST(EREMOTE);
- GET_CONST(EBADRPC);
- GET_CONST(ERPCMISMATCH);
- GET_CONST(EPROGUNAVAIL);
- GET_CONST(EPROGMISMATCH);
- GET_CONST(EPROCUNAVAIL);
- GET_CONST(EFTYPE);
- GET_CONST(EAUTH);
- GET_CONST(ECANCELED);
-#endif
-
-#if defined(__OpenBSD__)
- GET_CONST(EAUTH);
- GET_CONST(EBADRPC);
- GET_CONST(ECANCELED);
- GET_CONST(EDQUOT);
- GET_CONST(EFTYPE);
- GET_CONST(EILSEQ);
- GET_CONST(EIPSEC);
- GET_CONST(EMEDIUMTYPE);
- GET_CONST(ENEEDAUTH);
- GET_CONST(ENOATTR);
- GET_CONST(ENOMEDIUM);
- GET_CONST(ENOTSUP);
- GET_CONST(EOPNOTSUPP);
- GET_CONST(EOVERFLOW);
- GET_CONST(EPROCLIM);
- GET_CONST(EPROCUNAVAIL);
- GET_CONST(EPROGMISMATCH);
- GET_CONST(EPROGUNAVAIL);
- GET_CONST(EREMOTE);
- GET_CONST(ERPCMISMATCH);
- GET_CONST(ESTALE);
- GET_CONST(EUSERS);
-#endif
-
-#ifdef DARWIN
- GET_CONST(EPWROFF);
- GET_CONST(EDEVERR);
- GET_CONST(EBADEXEC);
- GET_CONST(EBADARCH);
- GET_CONST(ESHLIBVERS);
- GET_CONST(EBADMACHO);
- GET_CONST(EMULTIHOP);
- GET_CONST(ENODATA);
- GET_CONST(ENOLINK);
- GET_CONST(ENOSR);
- GET_CONST(ENOSTR);
- GET_CONST(ETIME);
- GET_CONST(EOPNOTSUPP);
- GET_CONST(ENOPOLICY);
- GET_CONST(EQFULL);
-#endif
-
-#if defined(__FreeBSD__) || defined(__DragonFly__)
- GET_CONST(EDOOFUS);
- GET_CONST(EMULTIHOP);
- GET_CONST(ENOLINK);
-#endif
-
-#ifdef __FreeBSD__
- GET_CONST(ENOTCAPABLE);
- GET_CONST(ECAPMODE);
-#endif
-
- return -1;
-
-}
diff --git a/nix-test/src/lib.rs b/nix-test/src/lib.rs
deleted file mode 100644
index cfe7b798..00000000
--- a/nix-test/src/lib.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-extern crate libc;
-
-use std::fmt;
-use std::ffi::CString;
-use libc::{c_int, c_char};
-
-mod ffi {
- use libc::{c_int, c_char, size_t};
-
- #[link(name = "nixtest", kind = "static")]
- extern {
- pub fn get_int_const(errno: *const c_char) -> c_int;
- pub fn size_of(ty: *const c_char) -> size_t;
- }
-}
-
-pub fn assert_const_eq<T: GetConst>(name: &str, actual: T) {
- unsafe {
- let cstr = CString::new(name).unwrap();
- let expect = GetConst::get_const(cstr.as_ptr());
-
- if actual != expect {
- panic!("incorrect value for errno {}; expect={}; actual={}",
- name, expect, actual);
- }
- }
-}
-
-pub fn assert_size_of<T>(name: &str) {
- use std::mem;
-
- unsafe {
- let cstr = CString::new(name).unwrap();
- let expect = ffi::size_of(cstr.as_ptr()) as usize;
-
- assert!(expect > 0, "undefined type {}", name);
-
- if mem::size_of::<T>() != expect {
- panic!("incorrectly sized type; expect={}; actual={}",
- expect, mem::size_of::<T>());
- }
- }
-}
-
-pub use ffi::get_int_const;
-
-pub trait GetConst : PartialEq<Self> + fmt::Display {
- unsafe fn get_const(name: *const c_char) -> Self;
-}
-
-impl GetConst for c_int {
- unsafe fn get_const(name: *const c_char) -> c_int {
- ffi::get_int_const(name)
- }
-}
-
-impl GetConst for u32 {
- unsafe fn get_const(name: *const c_char) -> u32 {
- ffi::get_int_const(name) as u32
- }
-}
diff --git a/nix-test/src/sizes.c b/nix-test/src/sizes.c
deleted file mode 100644
index ca862003..00000000
--- a/nix-test/src/sizes.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <sys/socket.h>
-#include <sys/uio.h>
-
-#include <string.h>
-
-#define SIZE_OF_T(TYPE) \
- do { \
- if (0 == strcmp(type, #TYPE)) { \
- return sizeof(TYPE); \
- } \
- } while (0)
-
-#define SIZE_OF_S(TYPE) \
- do { \
- if (0 == strcmp(type, #TYPE)) { \
- return sizeof(struct TYPE); \
- } \
- } while (0)
-
-size_t
-size_of(const char* type) {
- // Builtin
- SIZE_OF_T(long);
-
- // sys/socket
- SIZE_OF_S(sockaddr_storage);
-
- // sys/uio
- SIZE_OF_S(iovec);
-
- return 0;
-}