[pypy-svn] r16668 - in pypy/release/0.7.x/pypy/translator/llvm: module test

rxe at codespeak.net rxe at codespeak.net
Fri Aug 26 19:08:39 CEST 2005


Author: rxe
Date: Fri Aug 26 19:08:38 2005
New Revision: 16668

Modified:
   pypy/release/0.7.x/pypy/translator/llvm/module/genexterns.c
   pypy/release/0.7.x/pypy/translator/llvm/test/test_extfunc.py
Log:
Added ll_os_rmdir ll_os_mkdir ll_os_chdir to externs.


Modified: pypy/release/0.7.x/pypy/translator/llvm/module/genexterns.c
==============================================================================
--- pypy/release/0.7.x/pypy/translator/llvm/module/genexterns.c	(original)
+++ pypy/release/0.7.x/pypy/translator/llvm/module/genexterns.c	Fri Aug 26 19:08:38 2005
@@ -385,9 +385,9 @@
 
 
 double pypy_ll_strtod_parts_to_float(struct RPyString *sign, 
-				struct RPyString *beforept, 
-				struct RPyString *afterpt, 
-				struct RPyString *exponent)
+				     struct RPyString *beforept, 
+				     struct RPyString *afterpt, 
+				     struct RPyString *exponent)
 {
 	char *fail_pos;
 	struct lconv *locale_data;
@@ -685,3 +685,24 @@
     RPYTHON_RAISE_OSERROR(errno);
   }
 }
+
+void pypy_ll_os_chdir(struct RPyString * path) {
+    int error = chdir(RPyString_AsString(path));
+    if (error != 0) {
+	RPYTHON_RAISE_OSERROR(errno);
+    }
+}
+
+void pypy_ll_os_mkdir(struct RPyString * path, int mode) {
+    int error = mkdir(RPyString_AsString(path), mode);
+    if (error != 0) {
+	RPYTHON_RAISE_OSERROR(errno);
+    }
+}
+
+void pypy_ll_os_rmdir(struct RPyString * path) {
+    int error = rmdir(RPyString_AsString(path));
+    if (error != 0) {
+	RPYTHON_RAISE_OSERROR(errno);
+    }
+}

Modified: pypy/release/0.7.x/pypy/translator/llvm/test/test_extfunc.py
==============================================================================
--- pypy/release/0.7.x/pypy/translator/llvm/test/test_extfunc.py	(original)
+++ pypy/release/0.7.x/pypy/translator/llvm/test/test_extfunc.py	Fri Aug 26 19:08:38 2005
@@ -254,4 +254,45 @@
     for i, s in enumerate(as_string):
         assert f(i)
 
+def test_os_unlink():
+    tmpfile = str(udir.join('test_os_path_exists.TMP'))
+    def fn():
+        os.unlink(tmpfile)
+        return 0
+    f = compile_function(fn, [])
+    open(tmpfile, 'w').close()
+    fn()
+    assert not os.path.exists(tmpfile)
+
+def test_chdir():
+    path = '..'
+    def does_stuff():
+        os.chdir(path)
+        return 0
+    f1 = compile_function(does_stuff, [])
+    curdir = os.getcwd()
+    try:
+        os.chdir()
+    except: pass # toplevel
+    def does_stuff2():
+        os.chdir(curdir)
+        return 0
+    f1 = compile_function(does_stuff2, [])
+    f1()
+    assert curdir == os.getcwd()
+
+def test_mkdir_rmdir():
+    path = str(udir.join('test_mkdir_rmdir'))
+    def does_stuff(delete):
+        if delete:
+            os.rmdir(path)
+        else:
+            os.mkdir(path, 0777)
+        return 0
+    f1 = compile_function(does_stuff, [bool])
+    f1(False)
+    assert os.path.exists(path) and os.path.isdir(path)
+    f1(True)
+    assert not os.path.exists(path)
+
 # end of tests taken from c backend



More information about the Pypy-commit mailing list