diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-05-28 20:15:51 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-05-28 20:15:51 +0100 |
commit | babc0846cc911b01a58a7385d30ad25889b7175a (patch) | |
tree | e8f67f7fc096185e0febbad35396ba3972eaa432 /java | |
parent | c41fe04a652437c920acb0e820762c53bf44a139 (diff) | |
download | libguestfs-babc0846cc911b01a58a7385d30ad25889b7175a.tar.gz libguestfs-babc0846cc911b01a58a7385d30ad25889b7175a.tar.xz libguestfs-babc0846cc911b01a58a7385d30ad25889b7175a.zip |
Add tests for bindings parameters, fix several broken bindings.
Diffstat (limited to 'java')
-rw-r--r-- | java/Bindtests.java | 50 | ||||
-rw-r--r-- | java/Makefile.am | 16 | ||||
-rw-r--r-- | java/com_redhat_et_libguestfs_GuestFS.c | 15 | ||||
-rwxr-xr-x | java/run-bindtests (renamed from java/run-java-test) | 7 | ||||
-rwxr-xr-x | java/run-java-tests | 24 |
5 files changed, 98 insertions, 14 deletions
diff --git a/java/Bindtests.java b/java/Bindtests.java new file mode 100644 index 00000000..c12fbb9e --- /dev/null +++ b/java/Bindtests.java @@ -0,0 +1,50 @@ +/* libguestfs generated file + * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. + * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. + * + * Copyright (C) 2009 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +import com.redhat.et.libguestfs.*; + +public class Bindtests { + public static void main (String[] argv) + { + try { + GuestFS g = new GuestFS (); + g.test0 ("abc", "def", new String[]{}, false, 0, "123", "456"); + g.test0 ("abc", null, new String[]{}, false, 0, "123", "456"); + g.test0 ("", "def", new String[]{}, false, 0, "123", "456"); + g.test0 ("", "", new String[]{}, false, 0, "123", "456"); + g.test0 ("abc", "def", new String[]{"1"}, false, 0, "123", "456"); + g.test0 ("abc", "def", new String[]{"1","2"}, false, 0, "123", "456"); + g.test0 ("abc", "def", new String[]{"1"}, true, 0, "123", "456"); + g.test0 ("abc", "def", new String[]{"1"}, false, -1, "123", "456"); + g.test0 ("abc", "def", new String[]{"1"}, false, -2, "123", "456"); + g.test0 ("abc", "def", new String[]{"1"}, false, 1, "123", "456"); + g.test0 ("abc", "def", new String[]{"1"}, false, 2, "123", "456"); + g.test0 ("abc", "def", new String[]{"1"}, false, 4095, "123", "456"); + g.test0 ("abc", "def", new String[]{"1"}, false, 0, "", ""); + + System.out.println ("EOF"); + } + catch (Exception exn) { + System.err.println (exn); + System.exit (1); + } + } +} diff --git a/java/Makefile.am b/java/Makefile.am index cc9891b6..633ecdad 100644 --- a/java/Makefile.am +++ b/java/Makefile.am @@ -28,6 +28,7 @@ java_sources = \ $(CPTH)/GuestFS.java java_tests = \ + Bindtests.java \ t/GuestFS005Load.java \ t/GuestFS010Launch.java \ t/GuestFS050LVCreate.java @@ -35,7 +36,8 @@ java_tests = \ EXTRA_DIST = \ $(java_sources) \ $(java_tests) \ - run-java-test + run-bindtests \ + run-java-tests CLEANFILES = doc-stamp @@ -86,16 +88,20 @@ install-data-hook: # Tests (not comprehensive). -TESTS = $(java_tests:.java=.class) +TESTS = run-bindtests run-java-tests TESTS_ENVIRONMENT = \ JAVA=$(JAVA) \ - CLASSPATH=t:libguestfs-$(VERSION).jar \ - LIBGUESTFS_PATH=$(top_builddir)/appliance \ - ./run-java-test + CLASSPATH=.:t:libguestfs-$(VERSION).jar \ + LIBGUESTFS_PATH=$(top_builddir)/appliance + +noinst_DATA = Bindtests.class $(java_tests:.java=.class) t/%.class: t/%.java $(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar $< +Bindtests.class: Bindtests.java + $(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar $< + endif # Tell version 3.79 and up of GNU make to not build goals in this diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c index 37683bf5..c5971c58 100644 --- a/java/com_redhat_et_libguestfs_GuestFS.c +++ b/java/com_redhat_et_libguestfs_GuestFS.c @@ -78,7 +78,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1test0 int i; str = (*env)->GetStringUTFChars (env, jstr, NULL); - optstr = (*env)->GetStringUTFChars (env, joptstr, NULL); + optstr = joptstr ? (*env)->GetStringUTFChars (env, joptstr, NULL) : NULL; strlist_len = (*env)->GetArrayLength (env, jstrlist); strlist = guestfs_safe_malloc (g, sizeof (char *) * (strlist_len+1)); for (i = 0; i < strlist_len; ++i) { @@ -92,7 +92,8 @@ Java_com_redhat_et_libguestfs_GuestFS__1test0 fileout = (*env)->GetStringUTFChars (env, jfileout, NULL); r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout); (*env)->ReleaseStringUTFChars (env, jstr, str); - (*env)->ReleaseStringUTFChars (env, joptstr, optstr); + if (joptstr) + (*env)->ReleaseStringUTFChars (env, joptstr, optstr); for (i = 0; i < strlist_len; ++i) { jobject o = (*env)->GetObjectArrayElement (env, jstrlist, i); (*env)->ReleaseStringUTFChars (env, o, strlist[i]); @@ -1097,10 +1098,11 @@ Java_com_redhat_et_libguestfs_GuestFS__1config const char *qemuvalue; qemuparam = (*env)->GetStringUTFChars (env, jqemuparam, NULL); - qemuvalue = (*env)->GetStringUTFChars (env, jqemuvalue, NULL); + qemuvalue = jqemuvalue ? (*env)->GetStringUTFChars (env, jqemuvalue, NULL) : NULL; r = guestfs_config (g, qemuparam, qemuvalue); (*env)->ReleaseStringUTFChars (env, jqemuparam, qemuparam); - (*env)->ReleaseStringUTFChars (env, jqemuvalue, qemuvalue); + if (jqemuvalue) + (*env)->ReleaseStringUTFChars (env, jqemuvalue, qemuvalue); if (r == -1) { throw_exception (env, guestfs_last_error (g)); return ; @@ -1928,10 +1930,11 @@ Java_com_redhat_et_libguestfs_GuestFS__1aug_1defvar const char *expr; name = (*env)->GetStringUTFChars (env, jname, NULL); - expr = (*env)->GetStringUTFChars (env, jexpr, NULL); + expr = jexpr ? (*env)->GetStringUTFChars (env, jexpr, NULL) : NULL; r = guestfs_aug_defvar (g, name, expr); (*env)->ReleaseStringUTFChars (env, jname, name); - (*env)->ReleaseStringUTFChars (env, jexpr, expr); + if (jexpr) + (*env)->ReleaseStringUTFChars (env, jexpr, expr); if (r == -1) { throw_exception (env, guestfs_last_error (g)); return 0; diff --git a/java/run-java-test b/java/run-bindtests index 905360df..b80c4dc5 100755 --- a/java/run-java-test +++ b/java/run-bindtests @@ -1,5 +1,5 @@ #!/bin/sh - -# libguestfs Java bindings +# libguestfs Perl bindings # Copyright (C) 2009 Red Hat Inc. # # This program is free software; you can redistribute it and/or modify @@ -16,6 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -cmd=$(echo $1 | sed -e 's,^./t/,,' -e 's,.class$,,') +set -e -$JAVA -Djava.library.path=.libs $cmd +$JAVA -Djava.library.path=.libs Bindtests > bindtests.tmp +diff -u ../bindtests bindtests.tmp diff --git a/java/run-java-tests b/java/run-java-tests new file mode 100755 index 00000000..84471600 --- /dev/null +++ b/java/run-java-tests @@ -0,0 +1,24 @@ +#!/bin/sh - +# libguestfs Perl bindings +# Copyright (C) 2009 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +set -e + +for f in t/*.class; do + classname=$(basename $f .class) + $JAVA -Djava.library.path=.libs $classname +done
\ No newline at end of file |