List:Commits« Previous MessageNext Message »
From:Martin Zaun Date:September 28 2010 8:22am
Subject:bzr commit into mysql-5.1-telco-7.1 branch (martin.zaun:3838)
View as plain text  
#At file:///Users/mz/mysql/ndb-7.1/ based on revid:martin.zaun@stripped

 3838 Martin Zaun	2010-09-28 [merge]
      ndbjtie - merge minor fixes of jtie unit tests

    modified:
      storage/ndb/src/ndbjtie/jtie/test/myapi/myapi.cpp
      storage/ndb/src/ndbjtie/jtie/test/myapi/myapi.hpp
      storage/ndb/src/ndbjtie/jtie/test/myapi/myapi_test.cpp
      storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/A.java
      storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/B0.java
      storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/B1.java
      storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/MyJapi.java
      storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi_lib.cpp
      storage/ndb/src/ndbjtie/jtie/test/myjapi/test/MyJapiTest.java
=== modified file 'storage/ndb/src/ndbjtie/jtie/test/myapi/myapi.cpp'
--- a/storage/ndb/src/ndbjtie/jtie/test/myapi/myapi.cpp	2010-02-13 08:01:08 +0000
+++ b/storage/ndb/src/ndbjtie/jtie/test/myapi/myapi.cpp	2010-09-28 08:19:43 +0000
@@ -25,30 +25,156 @@
 #include "myapi.hpp"
 #include "helpers.hpp"
 
-void f0()
-{
-    TRACE("void f0()");
-}
-
+// ---------------------------------------------------------------------------
+// static initializations
 // ---------------------------------------------------------------------------
 
-A * A::a = new A();
-
-int32_t A::d0s = 10;
-const int32_t A::d0sc = -10;
 int32_t B0::d0s = 20;
 const int32_t B0::d0sc = -20;
+
 int32_t B1::d0s = 30;
 const int32_t B1::d0sc = -30;
 
-const C1 * const C1::cc = new C1();
-C1 * const C1::c = new C1();
-const C0 * const C0::cc = C1::cc;
-C0 * const C0::c = C1::c;
-
-D0 D0::d;
-D1 D1::d;
-D2 D2::d;
+A * A::a;
+int32_t A::d0s = 10;
+const int32_t A::d0sc = -10;
+
+void B0::init() {
+}
+
+void B0::finit() {
+}
+
+void B1::init() {
+}
+
+void B1::finit() {
+}
+
+void A::init() {
+    assert(!a);
+    a = new A();
+    //printf("    a = %p\n", a);
+}
+
+void A::finit() {
+    assert(a);
+    delete a;
+    a = NULL;
+}
+
+// ----------------------------------------
+
+const C0 * C0::cc;
+C0 * C0::c;
+
+const C1 * C1::cc;
+C1 * C1::c;
+
+void C0::init() {
+    assert(!c);
+    assert(!cc);
+    assert(C1::c);
+    assert(C1::cc);
+    c = C1::c;
+    cc = C1::cc;
+    //printf("    c = %p, cc = %p\n", C0::c, C0::cc);
+}
+
+void C0::finit() {
+    assert(c);
+    assert(cc);
+    c = NULL;
+    cc = NULL;
+}
+
+void C1::init() {
+    assert(!c);
+    assert(!cc);
+    c = new C1();
+    cc = new C1();
+    //printf("    c = %p, cc = %p\n", C1::c, C1::cc);
+}
+
+void C1::finit() {
+    assert(c);
+    assert(cc);
+    delete c;
+    delete cc;
+    c = NULL;
+    cc = NULL;
+}
+
+// ----------------------------------------
+
+D0 * D0::d;
+D1 * D1::d;
+D2 * D2::d;
+
+void D0::init() {
+    assert(!d);
+    d = new D0();
+}
+
+void D0::finit() {
+    assert(d);
+    delete d;
+    d = NULL;
+}
+
+void D1::init() {
+    assert(!d);
+    d = new D1();
+}
+
+void D1::finit() {
+    assert(d);
+    delete d;
+    d = NULL;
+}
+
+void D2::init() {
+    assert(!d);
+    d = new D2();
+}
+
+void D2::finit() {
+    assert(d);
+    delete d;
+    d = NULL;
+}
+
+// ----------------------------------------
+
+void myapi_init() {
+    // some order dependencies
+    D2::init();
+    D1::init();
+    D0::init();
+    C1::init();
+    C0::init();
+    B1::init();
+    B0::init();
+    A::init();
+}
+
+void myapi_finit() {
+    A::init();
+    B0::init();
+    B1::init();
+    C0::init();
+    C1::init();
+    D0::init();
+    D1::init();
+    D2::init();
+}
+
+// ---------------------------------------------------------------------------
+
+void f0()
+{
+    TRACE("void f0()");
+}
 
 // ---------------------------------------------------------------------------
 

=== modified file 'storage/ndb/src/ndbjtie/jtie/test/myapi/myapi.hpp'
--- a/storage/ndb/src/ndbjtie/jtie/test/myapi/myapi.hpp	2010-04-15 16:37:27 +0000
+++ b/storage/ndb/src/ndbjtie/jtie/test/myapi/myapi.hpp	2010-09-28 08:19:43 +0000
@@ -37,6 +37,18 @@
 
 #include "helpers.hpp"
 
+// ----------------------------------------------------------------------
+//  initializer and finalizer functions
+// ----------------------------------------------------------------------
+
+// initializer avoiding issues with static construction of objects
+extern void myapi_init();
+extern void myapi_finit();
+
+// ----------------------------------------------------------------------
+// void result/parameter types
+// ----------------------------------------------------------------------
+
 extern void f0();
 
 // ----------------------------------------------------------------------
@@ -452,6 +464,16 @@ extern void f784(double * const);
 // ----------------------------------------------------------------------
 
 struct B0 {
+    static int32_t d0s;
+    static const int32_t d0sc;
+
+    int32_t d0;
+    const int32_t d0c;
+
+    static void init();
+
+    static void finit();
+
     B0() : d0(21), d0c(-21) {
         TRACE("B0()");
     };
@@ -461,8 +483,7 @@ struct B0 {
         ABORT_ERROR("!USE OF COPY CONSTRUCTOR!");
     };
 
-    virtual ~B0() {
-    };
+    virtual ~B0() {};
 
     B0 & operator=(const B0 & p) {
         TRACE("B0 & operator=(const B0 &)");
@@ -473,13 +494,6 @@ struct B0 {
 
     // ----------------------------------------------------------------------
 
-    static int32_t d0s;
-    static const int32_t d0sc;
-    int32_t d0;
-    const int32_t d0c;
-
-    // ----------------------------------------------------------------------
-
     static int32_t f0s() {
         TRACE("int32_t B0::f0s()");
         return 20;
@@ -498,6 +512,16 @@ struct B0 {
 };
 
 struct B1 : public B0 {
+    static int32_t d0s;
+    static const int32_t d0sc;
+
+    int32_t d0;
+    const int32_t d0c;
+
+    static void init();
+
+    static void finit();
+
     B1() : d0(31), d0c(-31) {
         TRACE("B1()");
     };
@@ -507,8 +531,7 @@ struct B1 : public B0 {
         ABORT_ERROR("!USE OF COPY CONSTRUCTOR!");
     };
 
-    virtual ~B1() {
-    };
+    virtual ~B1() {};
 
     B1 & operator=(const B1 & p) {
         TRACE("B1 & operator=(const B1 &)");
@@ -519,13 +542,6 @@ struct B1 : public B0 {
 
     // ----------------------------------------------------------------------
 
-    static int32_t d0s;
-    static const int32_t d0sc;
-    int32_t d0;
-    const int32_t d0c;
-
-    // ----------------------------------------------------------------------
-
     static int32_t f0s() {
         TRACE("int32_t B1::f0s()");
         return 30;
@@ -544,6 +560,15 @@ struct B1 : public B0 {
 
 struct A {
     static A * a;
+    static int32_t d0s;
+    static const int32_t d0sc;
+
+    int32_t d0;
+    const int32_t d0c;
+
+    static void init();
+
+    static void finit();
 
     A() : d0(11), d0c(-11) {
         TRACE("A()");
@@ -572,16 +597,9 @@ struct A {
 
     // ----------------------------------------------------------------------
 
-    static int32_t d0s;
-    static const int32_t d0sc;
-    int32_t d0;
-    const int32_t d0c;
-
-    // ----------------------------------------------------------------------
-
     static A * deliver_ptr() {
         TRACE("A * A::deliver_ptr()");
-        return a;
+        return A::a;
     };
 
     static A * deliver_null_ptr() {
@@ -591,7 +609,7 @@ struct A {
 
     static A & deliver_ref() {
         TRACE("A & A::deliver_ref()");
-        return *a;
+        return *A::a;
     };
 
     static A & deliver_null_ref() {
@@ -621,9 +639,8 @@ struct A {
 
     static void print(A * p0) {
         TRACE("void A::print(A *)");
-        // in case of problems with %p
-        //printf("    p0 = %lx\n", (unsigned long)p0);
         printf("    p0 = %p\n", (void*)p0);
+        fflush(stdout);
     };
 
     // ----------------------------------------------------------------------
@@ -821,8 +838,15 @@ inline int32_t h3r(int8_t p0, int16_t p1
 // ----------------------------------------------------------------------
 
 struct C0 {
+    static C0 * c;
+    static const C0 * cc;
+
     const int64_t id;
 
+    static void init();
+
+    static void finit();
+
     C0() : id((int64_t)this) {
         TRACE("C0()");
     }
@@ -874,10 +898,6 @@ struct C0 {
     // (non-virtual) instance (on purpose) array functions
     // ----------------------------------------------------------------------
 
-    static C0 * const c;
-    static const C0 * const cc;
-    //printf("    cp = %p, c = %p, cc = %p\n", cp, C0::c, C0::cc);
-
     void check(int64_t id) const {
         TRACE("void check(int64_t) const");
         if (id != this->id) ABORT_ERROR("id != this->id");
@@ -885,7 +905,8 @@ struct C0 {
 
     void print() const {
         TRACE("void C0::print() const");
-        printf("    this->id = %lx\n", id);
+        printf("    this->id = %llx\n", id);
+        fflush(stdout);
     }
 
     const C0 * deliver_C0Cp() const {
@@ -934,6 +955,13 @@ struct C0 {
 };
 
 struct C1 : public C0 {
+    static C1 * c;
+    static const C1 * cc;
+
+    static void init();
+
+    static void finit();
+
     C1() {
         TRACE("C1()");
     };
@@ -985,10 +1013,6 @@ struct C1 : public C0 {
     // (non-virtual) instance (on purpose) array functions
     // ----------------------------------------------------------------------
 
-    static C1 * const c;
-    static const C1 * const cc;
-    //printf("    cp = %p, c = %p, cc = %p\n", cp, C1::c, C1::cc);
-
     const C1 * deliver_C1Cp() const {
         TRACE("const C1 * C1::deliver_C1Cp() const");
         return cc;
@@ -1041,36 +1065,45 @@ struct C1 : public C0 {
 struct D1;
 
 struct D0 {
+    static D0 * d;
+    static void init();
+    static void finit();
+    virtual ~D0() {}
+
     int f_d0() { TRACE("D0::f_d0()"); return 20; }
     int f_nv() { TRACE("D0::f_nv()"); return 21; }
     virtual int f_v() { TRACE("D0::f_v()"); return 22; }
     static D1 * sub();
-    static D0 d;
-    virtual ~D0() {}
 };
 
 struct D1 : D0 {
+    static D1 * d;
+    static void init();
+    static void finit();
+    virtual ~D1() {}
+
     int f_d1() { TRACE("D0::f_d1()"); return 30; }
     int f_nv() { TRACE("D1::f_nv()"); return 31; }
     virtual int f_v() { TRACE("D1::f_v()"); return 32; }
     static D1 * sub();
-    static D1 d;
-    virtual ~D1() {}
 };
 
 struct D2 : D1 {
+    static D2 * d;
+    static void init();
+    static void finit();
+    virtual ~D2() {}
+
     int f_d2() { TRACE("D2::f_d2()"); return 40; }
     int f_nv() { TRACE("D2::f_nv()"); return 41; }
     virtual int f_v() { TRACE("D2::f_v()"); return 42; }
     static D1 * sub();
-    static D2 d;
-    virtual ~D2() {}
 };
 
 // d1class instance returns (casts unnecessary but for attention)
-inline D1 * D0::sub() { TRACE("D1 * D0::sub()"); return ((D1*)&D1::d); }
-inline D1 * D1::sub() { TRACE("D1 * D1::sub()"); return ((D1*)&D2::d); }
-inline D1 * D2::sub() { TRACE("D1 * D2::sub()"); return NULL; }
+inline D1 * D0::sub() { TRACE("D1 * D0::sub()"); return ((D1*)D1::d); } // D1
+inline D1 * D1::sub() { TRACE("D1 * D1::sub()"); return ((D1*)D2::d); } // D2
+inline D1 * D2::sub() { TRACE("D1 * D2::sub()"); return NULL; }         // --
 
 // ----------------------------------------------------------------------
 // enums

=== modified file 'storage/ndb/src/ndbjtie/jtie/test/myapi/myapi_test.cpp'
--- a/storage/ndb/src/ndbjtie/jtie/test/myapi/myapi_test.cpp	2010-04-06 06:28:25 +0000
+++ b/storage/ndb/src/ndbjtie/jtie/test/myapi/myapi_test.cpp	2010-09-28 08:19:43 +0000
@@ -751,6 +751,8 @@ main(int argc, const char* argv[])
     printf("\n--> main()\n");
     (void)argc; (void)argv;
 
+    myapi_init();
+
     if (true) {
         test0();
         test1();
@@ -769,6 +771,8 @@ main(int argc, const char* argv[])
         test12();
     }
 
+    myapi_finit();
+
     printf("\n<-- main()\n");
     return 0;
 }

=== modified file 'storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/A.java'
--- a/storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/A.java	2010-04-06 06:28:25 +0000
+++ b/storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/A.java	2010-09-28 08:19:43 +0000
@@ -25,17 +25,9 @@ public class A extends com.mysql.jtie.Wr
     // this c'tor may me protected, for access from JNI is still possible
     // with default constructor, cdelegate needs to be written from JNI
     protected A() {
-        System.out.println("<-> myjapi.A()");
+        //System.out.println("<-> myjapi.A()");
     };
 
-/*
-    // this c'tor may me protected, for access from JNI is still possible
-    protected A(long cdelegate) {
-        super(cdelegate);
-        //System.out.println("<-> myjapi.A(" + Long.toHexString(cdelegate) + ")");
-    };
-*/
-
     // constructor wrapper (mapped by reference)
     static public native A create_r();
 

=== modified file 'storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/B0.java'
--- a/storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/B0.java	2010-04-06 06:28:25 +0000
+++ b/storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/B0.java	2010-09-28 08:19:43 +0000
@@ -25,17 +25,9 @@ public class B0 extends com.mysql.jtie.W
     // this c'tor may me protected, for access from JNI is still possible
     // with default constructor, cdelegate needs to be written from JNI
     protected B0() {
-        System.out.println("<-> myjapi.B0()");
+        //System.out.println("<-> myjapi.B0()");
     };
 
-/*
-    // this c'tor may me protected, for access from JNI is still possible
-    protected B0(long cdelegate) {
-        super(cdelegate);
-        //System.out.println("<-> myjapi.B0(" + Long.toHexString(cdelegate) + ")");
-    };
-*/
-
     // static method
     static public native int f0s();
 

=== modified file 'storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/B1.java'
--- a/storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/B1.java	2010-04-06 06:28:25 +0000
+++ b/storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/B1.java	2010-09-28 08:19:43 +0000
@@ -25,17 +25,9 @@ public class B1 extends B0 {
     // this c'tor may me protected, for access from JNI is still possible
     // with default constructor, cdelegate needs to be written from JNI
     protected B1() {
-        System.out.println("<-> myjapi.B1()");
+        //System.out.println("<-> myjapi.B1()");
     };
 
-/*
-    // this c'tor may me protected, for access from JNI is still possible
-    protected B1(long cdelegate) {
-        super(cdelegate);
-        //System.out.println("<-> myjapi.B1(" + Long.toHexString(cdelegate) + ")");
-    };
-*/
-
     // static method
     static public native int f0s();
 

=== modified file 'storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/MyJapi.java'
--- a/storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/MyJapi.java	2010-04-15 16:37:27 +0000
+++ b/storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi/MyJapi.java	2010-09-28 08:19:43 +0000
@@ -27,6 +27,10 @@ import java.nio.ByteBuffer;
 
 public class MyJapi {
 
+    // ----------------------------------------------------------------------
+    // Mapping of void result/parameters
+    // ----------------------------------------------------------------------
+
     static public native void f0();
 
     // ----------------------------------------------------------------------

=== modified file 'storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi_lib.cpp'
--- a/storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi_lib.cpp	2010-04-06 06:28:25 +0000
+++ b/storage/ndb/src/ndbjtie/jtie/test/myjapi/myjapi_lib.cpp	2010-09-28 08:19:43 +0000
@@ -69,6 +69,10 @@ JNI_OnLoad(JavaVM * jvm, void * reserved
         return JNI_ERR;
     }
 
+    VERBOSE("initializing the myapi resources ...");
+    myapi_init();
+    VERBOSE("... initialized the myapi resources");
+
     VERBOSE("... loaded the MyJAPI JTie library");
     return required_jni_version;
 }
@@ -82,6 +86,10 @@ JNI_OnUnload(JavaVM * jvm, void * reserv
     TRACE("void JNI_OnUnload(JavaVM *, void *)");
     VERBOSE("unloading the MyJAPI JTie library...");
 
+    VERBOSE("releasing the myapi resources ...");
+    myapi_finit();
+    VERBOSE("... released the myapi resources");
+
     JTie_OnUnload(jvm, reserved);
 
     VERBOSE("... unloaded the MyJAPI JTie library");

=== modified file 'storage/ndb/src/ndbjtie/jtie/test/myjapi/test/MyJapiTest.java'
--- a/storage/ndb/src/ndbjtie/jtie/test/myjapi/test/MyJapiTest.java	2010-04-15 16:37:27 +0000
+++ b/storage/ndb/src/ndbjtie/jtie/test/myjapi/test/MyJapiTest.java	2010-09-28 08:19:43 +0000
@@ -2488,11 +2488,10 @@ public class MyJapiTest {
         out.println("\ncalling A.print()...");
         try {
             A.print(a);
-            assert (false); // XXX conflicts with catch...
+            throw new RuntimeException("Expected exception not thrown.");
         } catch (AssertionError e) {
             out.println("... successfully caught: " + e);
         }
-
         out.println("\ncalling A.deliver_ptr()...");
         A pa = A.deliver_ptr();
         assert (pa != null);
@@ -2517,7 +2516,7 @@ public class MyJapiTest {
         out.println("\ncalling A.deliver_null_ref()...");
         try {
             A.deliver_null_ref();
-            assert (false); // XXX conflicts with catch...
+            throw new RuntimeException("Expected exception not thrown.");
         } catch (AssertionError e) {
             out.println("... successfully caught: " + e);
         }
@@ -3292,88 +3291,88 @@ public class MyJapiTest {
         out.println("... ap = " + ap);
         assert (ap != null);
 
-        out.println();
+        out.println("\ncalling A.h0()...");
         A.h0();
 
-        out.println();
+        out.println("\ncalling A.h1(byte)...");
         A.h1((byte)1);
 
-        out.println();
+        out.println("\ncalling A.h2(byte), short)...");
         A.h2((byte)1, (short)2);
 
-        out.println();
-        A.h3((byte)1, (short)2, 3);
+        out.println("\ncalling A.h3(byte), short, int)...");
+        A.h3((byte)1, (short)2, (int)3);
 
-        out.println();
+        out.println("\ncalling A.h0r()...");
         n = A.h0r();
         assert (n == 0);
 
-        out.println();
+        out.println("\ncalling A.h1r(byte)...");
         n = A.h1r((byte)1);
         assert (n == 1);
 
-        out.println();
+        out.println("\ncalling A.h2r(byte, short)...");
         n = A.h2r((byte)1, (short)2);
         assert (n == 3);
 
-        out.println();
-        n = A.h3r((byte)1, (short)2, 3);
+        out.println("\ncalling A.h3r(byte, short, int)...");
+        n = A.h3r((byte)1, (short)2, (int)3);
         assert (n == 6);
 
-        out.println();
+        out.println("\ncalling a.g0c()...");
         a.g0c();
 
-        out.println();
+        out.println("\ncalling a.g1c(byte)...");
         a.g1c((byte)1);
 
-        out.println();
+        out.println("\ncalling a.g2c(byte, short)...");
         a.g2c((byte)1, (short)2);
 
-        out.println();
-        a.g3c((byte)1, (short)2, 3);
+        out.println("\ncalling a.g3c(byte, short, int)...");
+        a.g3c((byte)1, (short)2, (int)3);
 
-        out.println();
+        out.println("\ncalling a.g0()...");
         a.g0();
 
-        out.println();
+        out.println("\ncalling a.g1(byte)...");
         a.g1((byte)1);
 
-        out.println();
+        out.println("\ncalling a.g2(byte, short)...");
         a.g2((byte)1, (short)2);
 
-        out.println();
-        a.g3((byte)1, (short)2, 3);
+        out.println("\ncalling a.g3(byte, short, int)...");
+        a.g3((byte)1, (short)2, (int)3);
 
-        out.println();
+        out.println("\ncalling n = a.g0rc()...");
         n = a.g0rc();
         assert (n == 0);
 
-        out.println();
+        out.println("\ncalling n = a.g1rc(byte)...");
         n = a.g1rc((byte)1);
         assert (n == 1);
 
-        out.println();
+        out.println("\ncalling n = a.g2rc(byte, short)...");
         n = a.g2rc((byte)1, (short)2);
         assert (n == 3);
 
-        out.println();
-        n = a.g3rc((byte)1, (short)2, 3);
+        out.println("\ncalling n = a.g3rc(byte, short, int)...");
+        n = a.g3rc((byte)1, (short)2, (int)3);
         assert (n == 6);
 
-        out.println();
+        out.println("\ncalling n = a.g0r()...");
         n = a.g0r();
         assert (n == 0);
 
-        out.println();
+        out.println("\ncalling n = a.g1r(byte)...");
         n = a.g1r((byte)1);
         assert (n == 1);
 
-        out.println();
+        out.println("\ncalling n = a.g2r(byte, short)...");
         n = a.g2r((byte)1, (short)2);
         assert (n == 3);
 
-        out.println();
-        n = a.g3r((byte)1, (short)2, 3);
+        out.println("\ncalling n = a.g3r(byte, short, int)...");
+        n = a.g3r((byte)1, (short)2, (int)3);
         assert (n == 6);
 
         out.println("\ncalling A.delete_p(a)...");
@@ -3857,8 +3856,6 @@ public class MyJapiTest {
             test12();
         } else {
             out.println();
-            test10();
-            out.println();
             test12();
         }
 


Attachment: [text/bzr-bundle] bzr/martin.zaun@oracle.com-20100928082157-5lyf5ip07h1mbqdx.bundle
Thread
bzr commit into mysql-5.1-telco-7.1 branch (martin.zaun:3838) Martin Zaun28 Sep