Skip to content

Add unit and integration testing for the sketch recursive load functionality #462

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 6 commits into from
Oct 30, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test to check error throw on symlink loop detection
  • Loading branch information
Roberto Sora committed Oct 29, 2019
commit f1c28ff023c9daa24af413609accd832b01a3cba
54 changes: 54 additions & 0 deletions test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,60 @@ def test_compile_with_simple_sketch(run_command, data_dir):
assert is_message_sequence_in_json_log_traces(expected_trace_sequence, json_log_lines)


def test_compile_with_sketch_with_symlink_selfloop(run_command, data_dir):
# Init the environment explicitly
result = run_command("core update-index")
assert result.ok

# # Download latest AVR
result = run_command("core install arduino:avr")
assert result.ok

sketch_name = "CompileIntegrationTestSymlinkSelfLoop"
sketch_path = os.path.join(data_dir, sketch_name)
fqbn = "arduino:avr:uno"

# Create a test sketch
result = run_command("sketch new {}".format(sketch_path))
assert result.ok
assert "Sketch created in: {}".format(sketch_path) in result.stdout

# create a symlink that loops on himself
loop_file_path = os.path.join(sketch_path, "loop")
os.symlink(loop_file_path, loop_file_path)

# Build sketch for arduino:avr:uno
result = run_command(
"compile -b {fqbn} {sketch_path}".format(
fqbn=fqbn, sketch_path=sketch_path))
assert "Error during sketch processing: stat {loop_file_path}: too many levels of symbolic links".format(
loop_file_path=loop_file_path) in result.stderr
assert not result.ok

sketch_name = "CompileIntegrationTestSymlinkDirLoop"
sketch_path = os.path.join(data_dir, sketch_name)
fqbn = "arduino:avr:uno"

# Create a test sketch
result = run_command("sketch new {}".format(sketch_path))
assert result.ok
assert "Sketch created in: {}".format(sketch_path) in result.stdout

# create a symlink that loops on the upper level
loop_dir_path = os.path.join(sketch_path, "loop_dir")
os.mkdir(loop_dir_path)
loop_dir_symlink_path = os.path.join(loop_dir_path, "loop_dir_symlink")
os.symlink(loop_dir_path, loop_dir_symlink_path)

# Build sketch for arduino:avr:uno
result = run_command(
"compile -b {fqbn} {sketch_path}".format(
fqbn=fqbn, sketch_path=sketch_path))
assert "Filesystem bottom is too deep (directory recursion or filesystem really deep)".format(
loop_file_path=loop_file_path) in result.stderr
assert not result.ok


@pytest.mark.skipif(running_on_ci(), reason="VMs have no serial ports")
def test_compile_and_compile_combo(run_command, data_dir):
# Init the environment explicitly
Expand Down