Skip to content

Fix DebugServerTests issue #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Sources/OpenGraphCxx/DebugServer/og-debug-server.mm
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,18 @@

// log
os_log_info(misc_log(), "debug server graph://%s:%d/?token=%u", address, port, token);
fprintf(stderr, "debug server graph://%s:%d/?token=%u\\n", address, port, token);
fprintf(stderr, "debug server graph://%s:%d/?token=%u\n", address, port, token);
}

// TODO: To be implemented
OG::DebugServer::~DebugServer() {}
OG::DebugServer::~DebugServer() {
shutdown();
for (auto &connection : connections) {
connection.reset();
}
if (connections.data()) {
free(connections.data());
}
}

// TODO: select will fail here
void OG::DebugServer::run(int timeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

OG_ASSUME_NONNULL_BEGIN

OG_IMPLICIT_BRIDGING_ENABLED

namespace OG {
struct OGDebugServerMessageHeader {
uint32_t token;
Expand Down Expand Up @@ -61,6 +63,7 @@ typedef struct OGDebugServerStorage {
OG::DebugServer debugServer;
} OGDebugServerStorage;

OG_IMPLICIT_BRIDGING_DISABLED

OG_ASSUME_NONNULL_END

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import CoreFoundation
import Foundation
import Testing

@MainActor
struct DebugServerTests {
@Test
func testMode0() {
#expect(OGDebugServer.start(mode: 0) == nil)
#expect(OGDebugServer.copyURL() == nil)
}

// To make AG start debugServer, we need to pass internal_diagnostics check.
// In debug mode, we can breakpoint on `_ZN2AG11DebugServer5startEj` and
// executable `reg write w0 1` after `internal_diagnostics` call.
Expand All @@ -22,11 +23,12 @@ struct DebugServerTests {
.disabled(if: compatibilityTestEnabled, "Skip on AG due to internal_diagnostics check"),
)
func testMode1() throws {
_ = try #require(OGDebugServer.start(mode: 1))
let _ = try #require(OGDebugServer.start(mode: 1))
let url = try #require(OGDebugServer.copyURL())
let urlString = (url as URL).absoluteString
#expect(urlString.hasPrefix("graph://"))
OGDebugServer.run(timeout: 1)
OGDebugServer.stop()
}
}
#endif
2 changes: 1 addition & 1 deletion Tests/OpenGraphTests/DummyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// DummyTests.swift
// OpenGraphTests

@testable import OpenGraph
import OpenGraph
import Testing

struct DummyTests {}