Skip to content
Snippets Groups Projects
Commit 5cc52e4b authored by Paul Sajna's avatar Paul Sajna
Browse files

tests

parent fc92d95b
No related branches found
No related tags found
1 merge request!14implement some unistd
...@@ -4,7 +4,11 @@ const AT_FDCWD: c_int = -100; ...@@ -4,7 +4,11 @@ const AT_FDCWD: c_int = -100;
pub fn brk(addr: *const c_void) -> c_int { pub fn brk(addr: *const c_void) -> c_int {
unsafe { unsafe {
syscall!(BRK, addr) as c_int let newbrk = syscall!(BRK, addr);
if newbrk < addr as usize {
return -1
}
0
} }
} }
......
...@@ -190,13 +190,6 @@ pub extern "C" fn getchar_unlocked() -> c_int { ...@@ -190,13 +190,6 @@ pub extern "C" fn getchar_unlocked() -> c_int {
unimplemented!(); unimplemented!();
} }
#[no_mangle]
pub extern "C" fn getopt(argc: c_int,
argv: *const *const c_char,
optstring: c_char) -> c_int {
unimplemented!();
}
#[no_mangle] #[no_mangle]
pub extern "C" fn gets(s: *mut c_char) pub extern "C" fn gets(s: *mut c_char)
-> *mut c_char { -> *mut c_char {
......
...@@ -74,16 +74,6 @@ pub extern "C" fn crypt(key: *const c_char, salt: *const c_char) -> *mut c_char ...@@ -74,16 +74,6 @@ pub extern "C" fn crypt(key: *const c_char, salt: *const c_char) -> *mut c_char
unimplemented!(); unimplemented!();
} }
#[no_mangle]
pub extern "C" fn ctermid(s: *mut c_char) -> *mut c_char {
unimplemented!();
}
#[no_mangle]
pub extern "C" fn cuserid(s: *mut c_char) -> *mut c_char {
unimplemented!();
}
#[no_mangle] #[no_mangle]
pub extern "C" fn dup(fildes: c_int) -> c_int { pub extern "C" fn dup(fildes: c_int) -> c_int {
platform::dup(fildes) platform::dup(fildes)
......
/alloc /alloc
/args /args
/brk
/chdir
/create /create
/create.out /create.out
/dup
/dup.out
/fchdir
/fsync
/math /math
/printf /printf
/write /write
BINS=\ BINS=\
alloc \ alloc \
brk \
args \ args \
chdir \
create \ create \
dup \
fchdir \
fsync \
math \ math \
printf \ printf \
write write
......
...@@ -9,4 +9,12 @@ int main(int argc, char ** argv) { ...@@ -9,4 +9,12 @@ int main(int argc, char ** argv) {
ptr[i] = (char)i; ptr[i] = (char)i;
} }
free(ptr); free(ptr);
char * ptrc = (char *)calloc(256,1);
printf("calloc %p\n", ptrc);
for(int i = 0; i < 256; i++) {
ptrc[i] = (char)i;
}
free(ptrc);
} }
#include <unistd.h>
#include <stdio.h>
int main(int argc, char** argv) {
int status = brk((void*)100);
printf("brk exited with status code %d\n", status);
}
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
char* cwd1 = malloc(4096*sizeof(char));//(char*) calloc(4096 + 1, sizeof(char));
getcwd(cwd1, 4096);
printf("initial cwd: %s\n", cwd1);
free(cwd1);
chdir("..");
char* cwd2 = malloc(4096*sizeof(char));//(char*) calloc(4096 + 1, sizeof(char));
getcwd(cwd2, 4096);
printf("final cwd: %s\n", cwd2);
free(cwd2);
}
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(int argc, char** argv) {
creat("dup.out", 0777);
int fd1 = open("dup.out", 0, 0);
int fd2 = dup(fd1);
printf("fd %d duped into fd %d\n", fd1, fd2);
close(fd1);
close(fd2);
int fd3 = open("dup.out", 0x0002, 0x1000);
dup2(fd3, 1);
printf("hello fd %d", fd3);
close(fd3);
}
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main (int argc, char** argv) {
int fd = open("..", 0, 0);
int status;
status = fchdir(fd);
printf("fchdir exited with status code %d\n", status);
close(fd);
}
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main (int argc, char** argv) {
int fd = open(".", 0, 0);
int status;
status = fsync(fd);
printf("fsync exited with status code %d\n", status);
close(fd);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment