Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Molaro <lupus@oddwiz.org>2003-07-18 17:06:43 +0400
committerPaolo Molaro <lupus@oddwiz.org>2003-07-18 17:06:43 +0400
commita14e075557db01c2260646003379d3c246444e50 (patch)
treeae188bff17fd6292302e1dbe36d6ae88d6ffd7b5
parentc674f4d94e0a0924f7041c0e6fffa19d224d60f9 (diff)
Updates and fixes, mostly from Bernie Solomon <bernard@ugsolutions.com>.
svn path=/trunk/mono/; revision=16402
-rw-r--r--mono/tests/Makefile.am2
-rw-r--r--mono/tests/codegen.cs5
-rwxr-xr-xmono/tests/fib.cs9
-rw-r--r--mono/tests/libtest.c64
-rwxr-xr-xmono/tests/marshal2.cs54
-rwxr-xr-xmono/tests/marshal4.cs2
-rw-r--r--mono/tests/marshal6.cs11
-rwxr-xr-xmono/tests/pinvoke.cs18
-rw-r--r--mono/tests/pinvoke11.cs4
-rwxr-xr-xmono/tests/pinvoke2.cs33
-rw-r--r--mono/tests/pointer.cs10
-rw-r--r--mono/tests/remoting5.cs3
-rw-r--r--mono/tests/sieve.cs4
13 files changed, 173 insertions, 46 deletions
diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am
index c4f1554c49e..432ee1fe076 100644
--- a/mono/tests/Makefile.am
+++ b/mono/tests/Makefile.am
@@ -258,6 +258,8 @@ check:
noinst_LTLIBRARIES = libtest.la
+INCLUDES = $(GLIB_CFLAGS)
+
libtest_la_LDFLAGS = -rpath `pwd`
libtest_la_SOURCES = libtest.c
diff --git a/mono/tests/codegen.cs b/mono/tests/codegen.cs
index 76f02358a3e..8886255cefd 100644
--- a/mono/tests/codegen.cs
+++ b/mono/tests/codegen.cs
@@ -39,6 +39,11 @@ class CGen {
Type t = tbuilder.CreateType ();
abuilder.SetEntryPoint (method);
abuilder.Save (name);
+ Console.WriteLine ("abuilder == module.assembly: {0}", abuilder == mbuilder.Assembly);
+ Console.WriteLine ("abuilder == type.assembly: {0}", abuilder == t.Assembly);
+ Console.WriteLine ("abuilder == tbuilder.assembly: {0}", abuilder == tbuilder.Assembly);
+ Console.WriteLine ("mbuilder == type.Module: {0}", mbuilder == t.Module);
+ Console.WriteLine ("mbuilder == tbuilder.Module: {0}", mbuilder == tbuilder.Module);
return 0;
}
}
diff --git a/mono/tests/fib.cs b/mono/tests/fib.cs
index 212889482a0..eca6065a178 100755
--- a/mono/tests/fib.cs
+++ b/mono/tests/fib.cs
@@ -13,12 +13,17 @@ public class Fib {
if (args.Length == 1)
repeat = Convert.ToInt32 (args [0]);
- Console.WriteLine ("Repeat = " + repeat);
+// Console.WriteLine ("Repeat = " + repeat);
+ if (repeat > 32) {
+ Console.WriteLine ("{0}", fib (repeat));
+ return 0;
+ }
+
for (int i = 0; i < repeat; i++)
if (fib (32) != 3524578)
return 1;
-
+
return 0;
}
}
diff --git a/mono/tests/libtest.c b/mono/tests/libtest.c
index 77606e33b64..02986448032 100644
--- a/mono/tests/libtest.c
+++ b/mono/tests/libtest.c
@@ -1,5 +1,7 @@
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <glib.h>
unsigned short*
test_lpwstr_marshal (unsigned short* chars, long length)
@@ -36,6 +38,28 @@ int mono_return_int (int a) {
printf ("Got value %d\n", a);
return a;
}
+
+struct ss
+{
+ int i;
+};
+
+int mono_return_int_ss (struct ss a) {
+ printf ("Got value %d\n", a.i);
+ return a.i;
+}
+
+union su
+{
+ int i1;
+ int i2;
+};
+
+int mono_return_int_su (union su a) {
+ printf ("Got value %d\n", a.i1);
+ return a.i1;
+}
+
int mono_test_many_int_arguments (int a, int b, int c, int d, int e,
int f, int g, int h, int i, int j);
short mono_test_many_short_arguments (short a, short b, short c, short d, short e,
@@ -61,6 +85,18 @@ mono_test_many_byte_arguments (char a, char b, char c, char d, char e, char f, c
return a + b + c + d + e + f + g + h + i + j;
}
+float
+mono_test_many_float_arguments (float a, float b, float c, float d, float e, float f, float g, float h, float i, float j)
+{
+ return a + b + c + d + e + f + g + h + i + j;
+}
+
+double
+mono_test_many_double_arguments (double a, double b, double c, double d, double e, double f, double g, double h, double i, double j)
+{
+ return a + b + c + d + e + f + g + h + i + j;
+}
+
int
mono_test_puts_static (char *s)
{
@@ -208,6 +244,28 @@ mono_test_marshal_struct (simplestruct ss)
return 1;
}
+typedef struct {
+ int a;
+ int b;
+ int c;
+ char *d;
+ unsigned char e;
+ double f;
+ unsigned char g;
+ guint64 h;
+} simplestruct2;
+
+int
+mono_test_marshal_struct2 (simplestruct2 ss)
+{
+ if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
+ !strcmp (ss.d, "TEST") &&
+ ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
+ return 0;
+
+ return 1;
+}
+
typedef int (*SimpleDelegate) (int a);
@@ -245,8 +303,10 @@ mono_test_marshal_stringbuilder (char *s, int n)
return 0;
}
+#ifdef __GNUC__
typedef struct {
} EmptyStruct;
+#endif
int
mono_test_marshal_string_array (char **array)
@@ -255,6 +315,7 @@ mono_test_marshal_string_array (char **array)
return 0;
}
+#ifdef __GNUC__
/* this does not work on Redhat gcc 2.96 */
int
mono_test_empty_struct (int a, EmptyStruct es, int b)
@@ -265,6 +326,7 @@ mono_test_empty_struct (int a, EmptyStruct es, int b)
return 0;
return 1;
}
+#endif
typedef struct {
char a[100];
@@ -276,7 +338,7 @@ mono_test_byvalstr_gen (void)
ByValStrStruct *ret;
int i;
- ret = g_malloc(sizeof(ByValStrStruct));
+ ret = malloc(sizeof(ByValStrStruct));
memset(ret, 'a', sizeof(ByValStrStruct)-1);
ret->a[sizeof(ByValStrStruct)-1] = 0;
diff --git a/mono/tests/marshal2.cs b/mono/tests/marshal2.cs
index 3611225470c..9ba085f63f0 100755
--- a/mono/tests/marshal2.cs
+++ b/mono/tests/marshal2.cs
@@ -64,74 +64,74 @@ public class Test {
if (Marshal.ReadInt32 (p, (int)Marshal.OffsetOf (t, "a")) != 1)
return 1;
if (Marshal.ReadInt32 (p, (int)Marshal.OffsetOf (t, "bool1")) != 1)
- return 1;
+ return 2;
if (Marshal.ReadInt32 (p, (int)Marshal.OffsetOf (t, "bool2")) != 0)
- return 1;
+ return 3;
if (Marshal.ReadInt32 (p, (int)Marshal.OffsetOf (t, "b")) != 2)
- return 1;
+ return 4;
if (Marshal.ReadInt16 (p, 16) != 6)
- return 1;
+ return 5;
if (Marshal.ReadInt16 (p, 18) != 5)
- return 1;
+ return 6;
if (Marshal.ReadByte (p, 20) != 97)
- return 1;
+ return 7;
if (Marshal.ReadByte (p, 21) != 98)
- return 1;
+ return 8;
if (Marshal.ReadByte (p, 22) != 99)
- return 1;
+ return 9;
if (Marshal.ReadByte (p, 23) != 0)
- return 1;
+ return 10;
if (Marshal.ReadInt32 (p, 24) != 3)
- return 1;
+ return 11;
if (Marshal.ReadInt32 (p, 28) != 4)
- return 1;
+ return 12;
if (Marshal.ReadInt32 (p, 32) != 10)
- return 1;
+ return 13;
if (Marshal.ReadInt32 (p, 36) != 11)
- return 1;
+ return 14;
if (Marshal.ReadInt32 (p, (int)Marshal.OffsetOf (t, "s2")) == 0)
- return 1;
+ return 15;
SimpleStruct cp = (SimpleStruct)Marshal.PtrToStructure (p, ss.GetType ());
if (cp.a != 1)
- return 2;
+ return 16;
if (cp.bool1 != true)
- return 2;
+ return 17;
if (cp.bool2 != false)
- return 2;
+ return 18;
if (cp.b != 2)
- return 2;
+ return 19;
if (cp.a1 [0] != 6)
- return 2;
+ return 20;
if (cp.a1 [1] != 5)
- return 2;
+ return 21;
if (cp.s1 != "abc")
- return 3;
+ return 22;
if (cp.emb1.a != 3)
- return 2;
+ return 23;
if (cp.emb1.b != 4)
- return 2;
+ return 24;
if (cp.emb2.a != 10)
- return 2;
+ return 25;
if (cp.emb2.b != 11)
- return 2;
+ return 26;
if (cp.s2 != "just a test")
- return 2;
+ return 27;
if (cp.x != 1.5)
- return 2;
+ return 28;
return 0;
}
diff --git a/mono/tests/marshal4.cs b/mono/tests/marshal4.cs
index 9c01521306b..48d86adc634 100755
--- a/mono/tests/marshal4.cs
+++ b/mono/tests/marshal4.cs
@@ -24,7 +24,7 @@ public class Test {
int size = Marshal.SizeOf (typeof (DelegateStruct));
Console.WriteLine ("DelegateStruct:" + size);
- if (size != 8)
+ if (size != 2 * sizeof(void *)) // not right for 64 bit pointers which can be 4 byte aligned
return 1;
ss.a = 123;
diff --git a/mono/tests/marshal6.cs b/mono/tests/marshal6.cs
index 3e4a997d2cb..fde486cd4af 100644
--- a/mono/tests/marshal6.cs
+++ b/mono/tests/marshal6.cs
@@ -17,7 +17,16 @@ public class X {
IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Dummy)));
Marshal.StructureToPtr(dummy, p, false);
- if(Marshal.ReadInt32(p, 0) != 0x64636261) {
+ if(Marshal.ReadByte(p, 0) != 0x61) {
+ return 1;
+ }
+ if(Marshal.ReadByte(p, 1) != 0x62) {
+ return 1;
+ }
+ if(Marshal.ReadByte(p, 2) != 0x63) {
+ return 1;
+ }
+ if(Marshal.ReadByte(p, 3) != 0x64) {
return 1;
}
return 0;
diff --git a/mono/tests/pinvoke.cs b/mono/tests/pinvoke.cs
index 81e4c13ea14..68d4ea6a6c7 100755
--- a/mono/tests/pinvoke.cs
+++ b/mono/tests/pinvoke.cs
@@ -15,6 +15,12 @@ public class Test {
[DllImport ("libtest.so", EntryPoint="mono_test_many_byte_arguments")]
public static extern int mono_test_many_byte_arguments (byte a, byte b, byte c, byte d, byte e,
byte f, byte g, byte h, byte i, byte j);
+ [DllImport ("libtest.so", EntryPoint="mono_test_many_float_arguments")]
+ public static extern float mono_test_many_float_arguments (float a, float b, float c, float d, float e,
+ float f, float g, float h, float i, float j);
+ [DllImport ("libtest.so", EntryPoint="mono_test_many_double_arguments")]
+ public static extern double mono_test_many_double_arguments (double a, double b, double c, double d, double e,
+ double f, double g, double h, double i, double j);
public static int Main () {
puts ("A simple Test for PInvoke");
@@ -22,13 +28,17 @@ public class Test {
if (Math.Cos (Math.PI) != -1)
return 1;
if (Math.Acos (1) != 0)
- return 1;
+ return 2;
if (mono_test_many_int_arguments (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) != 10)
- return 1;
+ return 3;
if (mono_test_many_short_arguments (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) != 55)
- return 1;
+ return 4;
if (mono_test_many_byte_arguments (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) != 55)
- return 1;
+ return 5;
+ if (mono_test_many_float_arguments (1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f) != 55.0f)
+ return 6;
+ if (mono_test_many_double_arguments (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0) != 55.0)
+ return 7;
return 0;
}
diff --git a/mono/tests/pinvoke11.cs b/mono/tests/pinvoke11.cs
index af1fccf00a8..87fb3c8c936 100644
--- a/mono/tests/pinvoke11.cs
+++ b/mono/tests/pinvoke11.cs
@@ -30,10 +30,10 @@ public class Test
[DllImport ("libtest.so")]
public static extern int mono_return_int (int a);
- [DllImport ("libtest.so", EntryPoint="mono_return_int")]
+ [DllImport ("libtest.so", EntryPoint="mono_return_int_ss")]
public static extern int mono_return_int_ss (ss a);
- [DllImport ("libtest.so", EntryPoint="mono_return_int")]
+ [DllImport ("libtest.so", EntryPoint="mono_return_int_su")]
public static extern int mono_return_int_su (su a);
static int Main()
diff --git a/mono/tests/pinvoke2.cs b/mono/tests/pinvoke2.cs
index a65d2349e1f..75bd3e7205c 100755
--- a/mono/tests/pinvoke2.cs
+++ b/mono/tests/pinvoke2.cs
@@ -21,6 +21,19 @@ public class Test {
public string d;
}
+ [StructLayout (LayoutKind.Sequential)]
+ public struct SimpleStruct2 {
+ public bool a;
+ public bool b;
+ public bool c;
+ public string d;
+ public byte e;
+ public double f;
+ public byte g;
+ public long h;
+ }
+
+
[DllImport ("libtest.so", EntryPoint="mono_test_marshal_char")]
public static extern int mono_test_marshal_char (char a1);
@@ -30,6 +43,9 @@ public class Test {
[DllImport ("libtest.so", EntryPoint="mono_test_marshal_struct")]
public static extern int mono_test_marshal_struct (SimpleStruct ss);
+ [DllImport ("libtest.so", EntryPoint="mono_test_marshal_struct2")]
+ public static extern int mono_test_marshal_struct2 (SimpleStruct2 ss);
+
[DllImport ("libtest.so", EntryPoint="mono_test_marshal_delegate")]
public static extern int mono_test_marshal_delegate (SimpleDelegate d);
@@ -49,13 +65,24 @@ public class Test {
SimpleStruct ss = new SimpleStruct ();
ss.b = true;
ss.d = "TEST";
- mono_test_marshal_struct (ss);
+ if (mono_test_marshal_struct (ss) != 0)
+ return 3;
+
+ SimpleStruct2 ss2 = new SimpleStruct2 ();
+ ss2.b = true;
+ ss2.d = "TEST";
+ ss2.e = 99;
+ ss2.f = 1.5;
+ ss2.g = 42;
+ ss2.h = 123L;
+ if (mono_test_marshal_struct2 (ss2) != 0)
+ return 4;
SimpleDelegate d = new SimpleDelegate (delegate_test);
if (mono_test_marshal_delegate (d) != 0)
- return 1;
-
+ return 5;
+
return 0;
}
}
diff --git a/mono/tests/pointer.cs b/mono/tests/pointer.cs
index 3cf97d2f959..b425801b481 100644
--- a/mono/tests/pointer.cs
+++ b/mono/tests/pointer.cs
@@ -16,15 +16,19 @@ public class Test {
return num;
num++;
- if (sizeof (void*) != 4)
+ if (sizeof (void*) != sizeof(IntPtr))
return num;
num++;
- if (sizeof (byte*) != 4)
+ if (sizeof (byte*) != sizeof (void *))
return num;
num++;
- if (sizeof (int*) != 4)
+ if (sizeof (int*) != sizeof (int *))
+ return num;
+
+ num++;
+ if (sizeof (IntPtr) != 4 && sizeof (IntPtr) != 8)
return num;
return 0;
diff --git a/mono/tests/remoting5.cs b/mono/tests/remoting5.cs
index f149e2f3d33..b57206dc7b7 100644
--- a/mono/tests/remoting5.cs
+++ b/mono/tests/remoting5.cs
@@ -73,6 +73,9 @@ class R1 : MarshalByRefObject {
if (o.test_field != 1)
return 1;
+ if (test_field != 1)
+ return 1;
+
return 0;
}
}
diff --git a/mono/tests/sieve.cs b/mono/tests/sieve.cs
index dbcd3aa2c24..0f4b3e8d88d 100644
--- a/mono/tests/sieve.cs
+++ b/mono/tests/sieve.cs
@@ -1,5 +1,5 @@
/* -*- mode: c -*-
- * $Id: sieve.cs,v 1.1 2001/11/19 06:52:53 lupus Exp $
+ * $Id: sieve.cs,v 1.2 2003/07/18 13:06:43 lupus Exp $
* http://www.bagley.org/~doug/shootout/
*/
@@ -26,7 +26,7 @@ static public int Main() {
}
}
}
- //printf("Count: %d\n", count);
+ System.Console.WriteLine("Count: {0}\n", count);
return(0);
}
}