Skip to content

CHG: MAssembly hardening and unit tests - #191

Open
zoglauer wants to merge 2 commits into
cositools:develop/emfrom
zoglauer:feature/massembly-unittest
Open

CHG: MAssembly hardening and unit tests#191
zoglauer wants to merge 2 commits into
cositools:develop/emfrom
zoglauer:feature/massembly-unittest

Conversation

@zoglauer

Copy link
Copy Markdown
Collaborator

Unit test, bug fixes, and hardening for MAssembly class

@zoglauer
zoglauer requested a review from fhagemann August 12, 2026 21:49
@zoglauer

Copy link
Copy Markdown
Collaborator Author

The crash here is a MEGAlib one which just happens on Ubuntu again - I have to fix that first

@zoglauer

Copy link
Copy Markdown
Collaborator Author

Fixed. Bug was in nuclearizer, not in MEGAlib.

Comment thread src/MAssembly.cxx
for (int i = 1; i < argc; i++) {
Option = argv[i];
if (Option == "-h" || Option == "--help" || Option == "?" || Option == "-?") {
if (Option == "--help" || Option == "-h" || Option == "-?" || Option == "?") {

@fhagemann fhagemann Aug 13, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest: why was the order of the Options changed? Is it good practice to have the written-out option first, so it's easier for people looking at the code which option is being processed by that code?

Comment thread src/MAssembly.cxx
return false;
}
int Verbosity = Value.ToInt();
if (Verbosity < c_Quiet || Verbosity > c_Info) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen in megalib that there is also c_Chatty and c_Extreme.
I guess we are not allowing for those in nuclearizer, hence they are excluded?
What if someone wants a "chatty" megalib?

Comment thread src/MAssembly.cxx
@@ -197,77 +185,120 @@ bool MAssembly::ParseCommandLine(int argc, char** argv)
Usage<<" Perform a test run to see if nuclearizer can be started up correctly."<<endl;
Usage<<" -v --verbosity:"<<endl;
Usage<<" Verbosity: 0: Quiet, 1: Errors, 2: Warnings, 3: Info"<<endl;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe for clarity (there's many colons here):

Suggested change
Usage<<" Verbosity: 0: Quiet, 1: Errors, 2: Warnings, 3: Info"<<endl;
Usage<<" Verbosity: 0 = Quiet, 1 = Errors, 2 = Warnings, 3 = Info"<<endl;

?

Comment thread src/MAssembly.cxx
Comment on lines 275 to 279
} else if (Option == "--test" || Option == "-t") {
// Parse later
} else if (Option == "--auto" || Option == "-a") {
// Parse later
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this? (I guess // Parse later refers to the // Now parse all high level options block later in this function?)

Comment thread include/MAssembly.h
MSupervisor* m_Supervisor;

//! The interrupt flag - the analysis will stop when this flag is set
bool m_Interrupt;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About m_Interrupt: is it correct that this was just not used before? I can only find m_Interrupt being used (but also defined) in the apps now.

Comment thread unittests/UTNAssembly.cxx
Comment on lines +463 to +470
{
char Arg0[] = "UTNAssembly";
char Arg1[] = "--verbosity";
char Arg2[] = "4";
vector<char*> Args = { Arg0, Arg1, Arg2 };
Passed = EvaluateFalse("ParseCommandLine()", "out-of-range --verbosity argument", "ParseCommandLine() returns false when verbosity is outside 0..3",
ParseSilently(Assembly, Args)) && Passed;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment above: this is intended that we do not want to support verbosity 4 and 5 in nuclearizer?

Comment thread unittests/UTNAssembly.cxx
Comment on lines +699 to +707
{
char Arg0[] = "UTNAssembly";
char Arg1[] = "-m";
char Arg2[] = "1";
vector<char*> Args = { Arg0, Arg1, Arg2 };
MString Output;
ParseAndCapture(Assembly, Args, Output);
Passed = EvaluateTrue("ParseCommandLine()", "-m 1", "-m 1 enables multithreading", Output.Contains("Command-line parser: Using multithreading: yes")) && Passed;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to confirm that MSupervisor::m_UseMultiThreading was actually set to true? Seems like m_UseMultiThreading is private, and there is no method to get it..

Comment thread unittests/UTNAssembly.cxx
vector<char*> Args = { Arg0, Arg1, Arg2 };
MString Output;
ParseAndCapture(Assembly, Args, Output);
Passed = EvaluateTrue("ParseCommandLine()", "--multithreading 0", "--multithreading 0 disables multithreading", Output.Contains("Command-line parser: Using multithreading: no")) && Passed;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here: can we check if m_UseMultiThreading in MSupervisor is actually false?

Comment thread unittests/UTNAssembly.cxx
Comment on lines +762 to +770
// A stray argument which is not an option is silently ignored
{
char Arg0[] = "UTNAssembly";
char Arg1[] = "SomeFile.roa";
vector<char*> Args = { Arg0, Arg1 };
MString Output;
ParseAndCapture(Assembly, Args, Output);
Passed = EvaluateFalse("ParseCommandLine()", "stray argument", "An argument which is not an option does not trigger an unknown-option warning", Output.Contains("Unknown option")) && Passed;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what we want?

Comment thread unittests/UTNAssembly.cxx
if (MGlobal::Initialize("UTNAssembly", "Unit tests for MAssembly") == false) return 1;

// An accepted command line ends in MSupervisor::LaunchUI(): make sure no test can ever
// open a window, no matter which options a future test case passes

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this comment more towards the top of the file (or duplicate it at the top), so that it's more visible, in case people were to add more unit tests? I don't think that I would scroll to the very bottom of the file if I were to add more unit tests.. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants