Skip to content

Commit

Permalink
Fix CI failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jbachorik committed Nov 9, 2024
1 parent 88f3ed5 commit f82f8cb
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 18 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@ jobs:
uses: gradle/actions/setup-gradle@v4
- name: Build
run: ./gradlew build
- name: Upload build data
- name: Upload dist build data
if: always()
uses: actions/upload-artifact@v4
with:
name: build
name: dist-build
retention-days: 1
path: |
btrace-dist/build
btrace-instr/build/classes/traces
- name: Upload test trace data
if: always()
uses: actions/upload-artifact@v4
with:
name: test-trace
retention-days: 1
path: |
btrace-instr/build/classes/traces
- name: Archive test reports
if: always()
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -77,8 +86,13 @@ jobs:
- name: Download build data
uses: actions/download-artifact@v4
with:
name: build
name: dist-build
path: btrace-dist/build
- name: Download test trace data
uses: actions/download-artifact@v4
with:
name: test-trace
path: btrace-instr/build/classes/traces
- name: Run tests
run: |
set +x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public byte[] transform(

className = className != null ? className : "<anonymous>";

// A special case for patching the Indy linking in order to be able to safely skip
// BTrace probes while linking is still in progress.
if (className.equals("java/lang/invoke/MethodHandleNatives")) {
byte[] transformed = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.objectweb.asm.Handle;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.openjdk.btrace.core.BTraceRuntime;
import org.openjdk.btrace.core.MethodID;
Expand Down
14 changes: 5 additions & 9 deletions btrace-instr/src/test/btrace/TraceAllTest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, Jaroslav Bachorik <[email protected]>.
* All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the Classpath exception as provided
* by Oracle in the LICENSE file that accompanied this code.
* published by the Free Software Foundation. Copyright owner designates
* this particular file as subject to the "Classpath" exception as provided
* by the owner in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
Expand All @@ -17,10 +18,6 @@
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package traces;
Expand All @@ -31,7 +28,6 @@

import java.util.concurrent.atomic.AtomicLong;


/**
*
* @author Jaroslav Bachorik
Expand Down
53 changes: 53 additions & 0 deletions integration-tests/src/test/btrace/TraceAllTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2024, Jaroslav Bachorik <[email protected]>.
* All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Copyright owner designates
* this particular file as subject to the "Classpath" exception as provided
* by the owner in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/

package traces;

import org.openjdk.btrace.core.annotations.*;
import org.openjdk.btrace.core.BTraceUtils;
import static org.openjdk.btrace.core.BTraceUtils.*;

import java.util.concurrent.atomic.AtomicLong;

/**
*
* @author Jaroslav Bachorik
*/
@BTrace(trusted = false)
public class TraceAllTest {

private static final AtomicLong hitCnt = BTraceUtils.newAtomicLong(0);

@OnMethod(clazz = "/.*/")
public static void doall(@ProbeMethodName(fqn = true) String pmn) {
BTraceUtils.getAndIncrement(hitCnt);
// BTraceUtils.println("invoked: " + pmn);
}

@OnTimer(500)
public static void doRecurrent() {
long cnt = BTraceUtils.get(hitCnt);
if (cnt > 0) {
println("[invocations=" + cnt + "]");
}
}
}
20 changes: 14 additions & 6 deletions integration-tests/src/test/java/tests/BTraceFunctionalTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package tests;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.assumeFalse;

import java.io.File;
import java.io.IOException;
Expand All @@ -36,6 +37,7 @@
import jdk.jfr.EventType;
import jdk.jfr.consumer.RecordedEvent;
import jdk.jfr.consumer.RecordingFile;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -176,13 +178,19 @@ public void validate(String stdout, String stderr, int retcode, String jfrFile)
public void testTraceAll() throws Exception {
String rtVersion = System.getProperty("java.runtime.version", "");
String testJavaHome = System.getenv().get("TEST_JAVA_HOME");

if (testJavaHome != null) {
Properties releaseProps = new Properties();
releaseProps.load(
Files.newInputStream(new File(testJavaHome + File.separator + "release").toPath()));
rtVersion = releaseProps.getProperty("JAVA_VERSION").replace("\"", "");
if (testJavaHome == null) {
testJavaHome = System.getenv("JAVA_HOME");
if (testJavaHome == null) {
testJavaHome = System.getProperty("java.home");
}
}

assumeFalse(testJavaHome == null);

Properties releaseProps = new Properties();
releaseProps.load(
Files.newInputStream(new File(testJavaHome + File.separator + "release").toPath()));
rtVersion = releaseProps.getProperty("JAVA_VERSION").replace("\"", "");
if (!isVersionSafeForTraceAll(rtVersion)) {
System.err.println("Skipping test for JDK " + rtVersion);
return;
Expand Down

0 comments on commit f82f8cb

Please sign in to comment.