Run threaded Err test on all hosts
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/77bf302a Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/77bf302a Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/77bf302a Branch: refs/heads/master Commit: 77bf302a287585ad4fd647254f13507f2648c7bb Parents: 901aa9c Author: Nick Wellnhofer <[email protected]> Authored: Sun May 10 18:41:29 2015 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Tue May 12 20:15:25 2015 +0200 ---------------------------------------------------------------------- runtime/c/src/Clownfish/Test/TestThreads.c | 61 ------------------------ runtime/core/Clownfish/Test.c | 2 - runtime/core/Clownfish/Test/TestErr.c | 36 +++++++++++++- runtime/core/Clownfish/Test/TestThreads.c | 28 ----------- runtime/core/Clownfish/Test/TestThreads.cfh | 28 ----------- runtime/perl/t/core/050-threads.t | 23 --------- runtime/perl/xs/XSBind.c | 10 +--- 7 files changed, 36 insertions(+), 152 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/77bf302a/runtime/c/src/Clownfish/Test/TestThreads.c ---------------------------------------------------------------------- diff --git a/runtime/c/src/Clownfish/Test/TestThreads.c b/runtime/c/src/Clownfish/Test/TestThreads.c deleted file mode 100644 index 4fd3bd3..0000000 --- a/runtime/c/src/Clownfish/Test/TestThreads.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define CFISH_USE_SHORT_NAMES -#define TESTCFISH_USE_SHORT_NAMES - -#include "charmony.h" - -#include "Clownfish/Test/TestThreads.h" - -#include "Clownfish/Err.h" -#include "Clownfish/String.h" -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Clownfish/TestHarness/TestUtils.h" - -static void -S_err_thread(void *arg) { - TestBatchRunner *runner = (TestBatchRunner*)arg; - - TEST_TRUE(runner, Err_get_error() == NULL, - "global error in thread initialized to null"); - - Err_set_error(Err_new(Str_newf("thread"))); -} - -static void -test_threads(TestBatchRunner *runner) { - if (!TestUtils_has_threads) { - SKIP(runner, 2, "no thread support"); - return; - } - - Err_set_error(Err_new(Str_newf("main"))); - - Thread *thread = TestUtils_thread_create(S_err_thread, runner, NULL); - TestUtils_thread_join(thread); - - String *mess = Err_Get_Mess(Err_get_error()); - TEST_TRUE(runner, Str_Equals_Utf8(mess, "main", 4), - "thread doesn't clobber global error"); -} - -void -TestThreads_Run_IMP(TestThreads *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 2); - test_threads(runner); -} - http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/77bf302a/runtime/core/Clownfish/Test.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test.c b/runtime/core/Clownfish/Test.c index 4212bff..9f03448 100644 --- a/runtime/core/Clownfish/Test.c +++ b/runtime/core/Clownfish/Test.c @@ -32,7 +32,6 @@ #include "Clownfish/Test/TestLockFreeRegistry.h" #include "Clownfish/Test/TestNum.h" #include "Clownfish/Test/TestObj.h" -#include "Clownfish/Test/TestThreads.h" #include "Clownfish/Test/TestVector.h" #include "Clownfish/Test/Util/TestAtomic.h" #include "Clownfish/Test/Util/TestMemory.h" @@ -56,7 +55,6 @@ Test_create_test_suite() { TestSuite_Add_Batch(suite, (TestBatch*)TestAtomic_new()); TestSuite_Add_Batch(suite, (TestBatch*)TestLFReg_new()); TestSuite_Add_Batch(suite, (TestBatch*)TestMemory_new()); - TestSuite_Add_Batch(suite, (TestBatch*)TestThreads_new()); return suite; } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/77bf302a/runtime/core/Clownfish/Test/TestErr.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test/TestErr.c b/runtime/core/Clownfish/Test/TestErr.c index b31313d..0497428 100644 --- a/runtime/core/Clownfish/Test/TestErr.c +++ b/runtime/core/Clownfish/Test/TestErr.c @@ -23,6 +23,7 @@ #include "Clownfish/Err.h" #include "Clownfish/Test.h" #include "Clownfish/TestHarness/TestBatchRunner.h" +#include "Clownfish/TestHarness/TestUtils.h" #include "Clownfish/Class.h" TestErr* @@ -41,10 +42,43 @@ test_To_String(TestBatchRunner *runner) { DECREF(error); } +static void +S_err_thread(void *arg) { + TestBatchRunner *runner = (TestBatchRunner*)arg; + + TEST_TRUE(runner, Err_get_error() == NULL, + "global error in thread initialized to null"); + + Err_set_error(Err_new(Str_newf("thread"))); + String *mess = Err_Get_Mess(Err_get_error()); + TEST_TRUE(runner, Str_Equals_Utf8(mess, "thread", 6), + "set_error in thread works"); +} + +static void +test_threads(TestBatchRunner *runner) { + if (!TestUtils_has_threads) { + SKIP(runner, 3, "no thread support"); + return; + } + + Err_set_error(Err_new(Str_newf("main"))); + + void *runtime = TestUtils_clone_host_runtime(); + Thread *thread = TestUtils_thread_create(S_err_thread, runner, runtime); + TestUtils_thread_join(thread); + TestUtils_destroy_host_runtime(runtime); + + String *mess = Err_Get_Mess(Err_get_error()); + TEST_TRUE(runner, Str_Equals_Utf8(mess, "main", 4), + "thread doesn't clobber global error"); +} + void TestErr_Run_IMP(TestErr *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 1); + TestBatchRunner_Plan(runner, (TestBatch*)self, 4); test_To_String(runner); + test_threads(runner); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/77bf302a/runtime/core/Clownfish/Test/TestThreads.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test/TestThreads.c b/runtime/core/Clownfish/Test/TestThreads.c deleted file mode 100644 index 054f9f0..0000000 --- a/runtime/core/Clownfish/Test/TestThreads.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define CFISH_USE_SHORT_NAMES -#define TESTCFISH_USE_SHORT_NAMES - -#include "Clownfish/Test/TestThreads.h" - -#include "Clownfish/Class.h" - -TestThreads* -TestThreads_new() { - return (TestThreads*)Class_Make_Obj(TESTTHREADS); -} - http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/77bf302a/runtime/core/Clownfish/Test/TestThreads.cfh ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test/TestThreads.cfh b/runtime/core/Clownfish/Test/TestThreads.cfh deleted file mode 100644 index 8406ab5..0000000 --- a/runtime/core/Clownfish/Test/TestThreads.cfh +++ /dev/null @@ -1,28 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestClownfish; - -class Clownfish::Test::TestThreads - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestThreads* - new(); - - void - Run(TestThreads *self, TestBatchRunner *runner); -} - http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/77bf302a/runtime/perl/t/core/050-threads.t ---------------------------------------------------------------------- diff --git a/runtime/perl/t/core/050-threads.t b/runtime/perl/t/core/050-threads.t deleted file mode 100644 index 48d636f..0000000 --- a/runtime/perl/t/core/050-threads.t +++ /dev/null @@ -1,23 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -use strict; -use warnings; - -use Clownfish::Test; -my $success = Clownfish::Test::run_tests("Clownfish::Test::TestThreads"); - -exit($success ? 0 : 1); - http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/77bf302a/runtime/perl/xs/XSBind.c ---------------------------------------------------------------------- diff --git a/runtime/perl/xs/XSBind.c b/runtime/perl/xs/XSBind.c index c8263eb..034c14a 100644 --- a/runtime/perl/xs/XSBind.c +++ b/runtime/perl/xs/XSBind.c @@ -25,7 +25,6 @@ #include "Clownfish/CharBuf.h" #include "Clownfish/HashIterator.h" #include "Clownfish/Method.h" -#include "Clownfish/Test/TestThreads.h" #include "Clownfish/TestHarness/TestUtils.h" #include "Clownfish/Util/Atomic.h" #include "Clownfish/Util/StringHelper.h" @@ -935,6 +934,7 @@ cfish_Err_get_error() { call_pv("Clownfish::Err::get_error", G_SCALAR); SPAGAIN; cfish_Err *error = (cfish_Err*)XSBind_perl_to_cfish(aTHX_ POPs); + if (error) { CFISH_CERTIFY(error, CFISH_ERR); } PUTBACK; FREETMPS; LEAVE; @@ -1072,11 +1072,3 @@ cfish_TestUtils_destroy_host_runtime(void *runtime) { perl_free(interp); } -/*********************** Clownfish::Test::TestThreads ***********************/ - -void -TESTCFISH_TestThreads_Run_IMP(testcfish_TestThreads *self, - cfish_TestBatchRunner *runner) { - CFISH_TestBatchRunner_Plan(runner, (cfish_TestBatch*)self, 0); -} -
