From f4396550a4140476fae085a4fe610edcefe1f15a Mon Sep 17 00:00:00 2001 From: mengxiaowei Date: Fri, 11 Jul 2025 11:11:02 +0800 Subject: [PATCH] clear StringTableConcurrentLoadStoreFuzzTest Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICLM2Q Signed-off-by: mengxiaowei Change-Id: If02afbc8d324c86b12345626d81ff2d5caa0136e --- test/fuzztest/BUILD.gn | 1 - .../BUILD.gn | 44 ----- .../corpus/init | 14 -- .../project.xml | 25 --- .../stringtableconcurrentloadstore_fuzzer.cpp | 166 ------------------ .../stringtableconcurrentloadstore_fuzzer.h | 21 --- test/resource/js_runtime/ohos_test.xml | 5 - 7 files changed, 276 deletions(-) delete mode 100644 test/fuzztest/stringtableconcurrentloadstore_fuzzer/BUILD.gn delete mode 100644 test/fuzztest/stringtableconcurrentloadstore_fuzzer/corpus/init delete mode 100644 test/fuzztest/stringtableconcurrentloadstore_fuzzer/project.xml delete mode 100644 test/fuzztest/stringtableconcurrentloadstore_fuzzer/stringtableconcurrentloadstore_fuzzer.cpp delete mode 100644 test/fuzztest/stringtableconcurrentloadstore_fuzzer/stringtableconcurrentloadstore_fuzzer.h diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 7c45425e29..19a98785cd 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -407,7 +407,6 @@ group("fuzztest") { "stringtableloadstore_fuzzer:fuzztest", "stringtableconcatstringintern_fuzzer:fuzztest", "stringtablehashcollision_fuzzer:fuzztest", - "stringtableconcurrentloadstore_fuzzer:fuzztest", "symbolnew_fuzzer:fuzztest", "symbolrefgetdescription_fuzzer:fuzztest", "tonativepointer_fuzzer:fuzztest", diff --git a/test/fuzztest/stringtableconcurrentloadstore_fuzzer/BUILD.gn b/test/fuzztest/stringtableconcurrentloadstore_fuzzer/BUILD.gn deleted file mode 100644 index 3ee3493ebc..0000000000 --- a/test/fuzztest/stringtableconcurrentloadstore_fuzzer/BUILD.gn +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed 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. - -##################################hydra-fuzz################################### -import("//arkcompiler/ets_runtime/js_runtime_config.gni") -import("//arkcompiler/ets_runtime/test/test_helper.gni") -import("//build/config/features.gni") -import("//build/ohos.gni") - -##################################fuzztest##################################### -ohos_fuzztest("StringTableConcurrentLoadStoreFuzzTest") { - module_out_path = ets_runtime_output_path - - fuzz_config_file = "$js_root/test/fuzztest/stringtableconcurrentloadstore_fuzzer" - - resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml" - - sources = [ "stringtableconcurrentloadstore_fuzzer.cpp" ] - - configs = [ "$js_root:ecma_test_config" ] - - deps = [ "$js_root:libark_jsruntime_test" ] - - # hiviewdfx libraries - external_deps = hiviewdfx_ext_deps - external_deps += [ sdk_libc_secshared_dep ] - deps += hiviewdfx_deps -} - -group("fuzztest") { - testonly = true - deps = [] - deps += [ ":StringTableConcurrentLoadStoreFuzzTest" ] -} diff --git a/test/fuzztest/stringtableconcurrentloadstore_fuzzer/corpus/init b/test/fuzztest/stringtableconcurrentloadstore_fuzzer/corpus/init deleted file mode 100644 index b690838e1c..0000000000 --- a/test/fuzztest/stringtableconcurrentloadstore_fuzzer/corpus/init +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed 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. - -FUZZ \ No newline at end of file diff --git a/test/fuzztest/stringtableconcurrentloadstore_fuzzer/project.xml b/test/fuzztest/stringtableconcurrentloadstore_fuzzer/project.xml deleted file mode 100644 index 66e1dcac47..0000000000 --- a/test/fuzztest/stringtableconcurrentloadstore_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/stringtableconcurrentloadstore_fuzzer/stringtableconcurrentloadstore_fuzzer.cpp b/test/fuzztest/stringtableconcurrentloadstore_fuzzer/stringtableconcurrentloadstore_fuzzer.cpp deleted file mode 100644 index 943cb942a0..0000000000 --- a/test/fuzztest/stringtableconcurrentloadstore_fuzzer/stringtableconcurrentloadstore_fuzzer.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed 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. - */ - -#include "stringtableconcurrentloadstore_fuzzer.h" -#include "ecmascript/base/string_helper.h" -#include "ecmascript/ecma_string-inl.h" -#include "ecmascript/ecma_string_table_optimization-inl.h" -#include "common_components/base/utf_helper.h" -#include "ecmascript/napi/include/jsnapi.h" -#include "ecmascript/napi/jsnapi_helper.h" -#include -#include - -using namespace panda; -using namespace panda::ecmascript; -using namespace common::utf_helper; - -namespace OHOS { - constexpr int DOUBLE_SEQUENCE = 2; - constexpr int TRIPLE_SEQUENCE = 3; - constexpr int FOUR_SEQUENCE = 4; - constexpr size_t TWO_BYTE_BITS = 16; - - bool IsValidMultiByteSequence(const uint8_t* data, size_t start, int seqLen, size_t size) - { - if (start + seqLen > size) { - return false; - } - - for (int j = 1; j < seqLen; j++) { - if ((data[start + j] & 0xC0) != 0x80) { - return false; - } - } - return true; - } - - void AddReplacementCharacter(std::vector& result) - { - result.push_back(0xEF); - result.push_back(0xBF); - result.push_back(0xBD); - } - - std::vector CreateValidUtf8(const uint8_t *data, size_t size) - { - std::vector result; - result.reserve(size); - for (size_t i = 0; i < size;) { - uint8_t byte = data[i]; - if (byte <= 0x7F) { - result.push_back(byte); - i++; - continue; - } - int seqLen = 0; - if ((byte & 0xE0) == 0xC0) { - seqLen = DOUBLE_SEQUENCE; - } else if ((byte & 0xF0) == 0xE0) { - seqLen = TRIPLE_SEQUENCE; - } else if ((byte & 0xF8) == 0xF0) { - seqLen = FOUR_SEQUENCE; - } - - if (seqLen == 0) { - AddReplacementCharacter(result); - i++; - continue; - } - if (IsValidMultiByteSequence(data, i, seqLen, size)) { - for (int j = 0; j < seqLen; j++) { - result.push_back(data[i + j]); - } - i += seqLen; - } else { - AddReplacementCharacter(result); - i++; - } - } - return result; - } - - struct ThreadWorkerArgs { - EcmaVM* vm; - common::HashTrieMap* map; - const std::vector* utf8Data; - size_t inputSize; - size_t processedUtf8Len; - int opsPerThread; - }; - - void ThreadWorker(const ThreadWorkerArgs& args) - { - JSThread* thread = args.vm->GetJSThread(); - for (int j = 0; j < args.opsPerThread; ++j) { - uint32_t key = (args.inputSize + j) % 0xFFFFFFFF; - size_t strLen = args.processedUtf8Len % TWO_BYTE_BITS; - - JSHandle value( - thread, - EcmaStringAccessor::CreateFromUtf8(args.vm, args.utf8Data->data(), strLen, true)); - - args.map->template LoadOrStore(thread, key, - [value]() { return value; }, - [](BaseString*) { return false; }); - } - } - - void StringTableConcurrentLoadStoreFuzzTest(const uint8_t *data, size_t size) - { - if (data == nullptr || size <= 0) { - LOG_ECMA(ERROR) << "illegal input!"; - return; - } - RuntimeOption option; - option.SetLogLevel(common::LOG_LEVEL::ERROR); - EcmaVM *vm = JSNApi::CreateJSVM(option); - - constexpr int threadCount = 4; - constexpr int opsPerThread = 10; - - auto *map = new common::HashTrieMap(); - std::vector utf8Data = CreateValidUtf8(data, size); - size_t utf8Len = utf8Data.size(); - - std::vector threads; - threads.reserve(threadCount); - ThreadWorkerArgs args{ - .vm = vm, - .map = map, - .utf8Data = &utf8Data, - .inputSize = size, - .processedUtf8Len = utf8Len, - .opsPerThread = opsPerThread - }; - - for (int i = 0; i < threadCount; ++i) { - threads.emplace_back(ThreadWorker, args); - } - for (auto &t : threads) { - t.join(); - } - delete map; - JSNApi::DestroyJSVM(vm); - } -} - -// Fuzzer entry point. -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - // Run your code on data. - OHOS::StringTableConcurrentLoadStoreFuzzTest(data, size); - return 0; -} \ No newline at end of file diff --git a/test/fuzztest/stringtableconcurrentloadstore_fuzzer/stringtableconcurrentloadstore_fuzzer.h b/test/fuzztest/stringtableconcurrentloadstore_fuzzer/stringtableconcurrentloadstore_fuzzer.h deleted file mode 100644 index 6e320b03b8..0000000000 --- a/test/fuzztest/stringtableconcurrentloadstore_fuzzer/stringtableconcurrentloadstore_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed 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. - */ - -#ifndef STRINGTABLECONCURRENTLOADSTORE_FUZZER_H -#define STRINGTABLECONCURRENTLOADSTORE_FUZZER_H - -#define FUZZ_PROJECT_NAME "stringtableconcurrentloadstore_fuzzer" - -#endif \ No newline at end of file diff --git a/test/resource/js_runtime/ohos_test.xml b/test/resource/js_runtime/ohos_test.xml index 9a17b95005..01f1128db8 100755 --- a/test/resource/js_runtime/ohos_test.xml +++ b/test/resource/js_runtime/ohos_test.xml @@ -1866,11 +1866,6 @@