Skip to content

Commit

Permalink
Bugfix #35 (XSectionGenerator::run not working)
Browse files Browse the repository at this point in the history
- Added tests for API (run_api_tests.sh)
- Version 1.10
  • Loading branch information
Matthias Koefferlein committed Jun 3, 2024
1 parent 2da6cec commit 1e67ff6
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
tests/run_dir
.*.swp
.*.swo
klayout_crash.log
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# Version 1.10 - 2024-06-03

* Bugfix issue #35 (XSectionGenerator::run not working)

# Version 1.9 - 2024-05-28

* Bugfix issue #34 ("XSection: Active Technology" not working in Windows)
Expand Down
2 changes: 1 addition & 1 deletion src/grain.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<salt-grain>
<name>xsection</name>
<version>1.9</version>
<version>1.10</version>
<api-version/>
<title>Ruby script</title>
<doc>A generator for vertical cross sections of layouts using a technology description file.</doc>
Expand Down
2 changes: 1 addition & 1 deletion src/macros/xsection.lym
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ require_relative("../ruby/xsection")
module XS

# UPDATE THE VERSION NUMBER ON EACH RELEASE HERE
VERSION = "1.9"
VERSION = "1.10"

@xsection_processing_environment = XSectionScriptEnvironment.new

Expand Down
2 changes: 1 addition & 1 deletion src/ruby/xsection_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def layers_file(lyp_file)

# The basic generation method (single segment)
def run(p1, p2, cv)
run_multi([ p1, p2 ])
run_multi([[ p1, p2 ]], cv)
end

# The basic generation method (multiple segments)
Expand Down
42 changes: 42 additions & 0 deletions tests/api_tests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

require "test/unit"
require 'test/unit/ui/console/testrunner'

# NOTE: these tests are more like smoke tests
# For the real tests, see "run_tests.sh"

class XSectionAPITest < Test::Unit::TestCase

def test_run

mw = RBA::MainWindow.instance
mw.load_layout($input_file, 1)

cv = RBA::CellView.active

gen = XS::XSectionGenerator.new($xs_file)
view = gen.run(RBA::DPoint.new(-1, 0), RBA::DPoint.new(1, 0), cv)

assert_equal("(-0.042,-2.058;2.058,0.042)", view.box.to_s)

end

def test_run_multi

mw = RBA::MainWindow.instance
mw.load_layout($input_file, 1)

cv = RBA::CellView.active

gen = XS::XSectionGenerator.new($xs_file)
view = gen.run_multi([[ RBA::DPoint.new(-1, 0), RBA::DPoint.new(0, 0) ], [ RBA::DPoint.new(0, 0), RBA::DPoint.new(1, 0) ]], cv)

assert_equal("(-0.042,-2.058;2.058,0.042)", view.box.to_s)

end

end

test_suite = XSectionAPITest.suite
Test::Unit::UI::Console::TestRunner.run(test_suite)

37 changes: 37 additions & 0 deletions tests/run_api_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash -e

export KLAYOUT_HOME=/dev/null

def_path_win="$HOME/AppData/Roaming/KLayout"
if [ -e "$def_path_win" ] && [ -d "$def_path_win" ]; then
echo "Adding default installation path: $def_path_win"
export PATH="$def_path_win:$PATH"
fi

# locate klayout binary
for exe in klayout klayout_app.exe; do
if which $exe 2>/dev/null; then
klayout=$(which $exe)
break
fi
done

if [ "$klayout" = "" ]; then
echo "No KLayout binary found in PATH .. please set path to point to klayout binary"
exit 1
fi

echo "Using KLayout binary from: $klayout"

rm -rf run_dir
mkdir -p run_dir

failed=""

bin=../src/macros/xsection.lym

export KLAYOUT_PATH=../src
export KLAYOUT_HOME=run_dir

$klayout -nc -z -r api_tests.rb -rd xs_file=xs_etch1.xs -rd input_file=xs_test.gds

2 changes: 1 addition & 1 deletion tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ for tc_file in $tc_files; do
xs_cut="-1,0;1,0"
fi

$klayout -rx -z -rd xs_run=$tc.xs -rd xs_cut="$xs_cut" -rd xs_out=run_dir/$tc.gds "$xs_input" -r $bin
$klayout -nc -rx -z -rd xs_run=$tc.xs -rd xs_cut="$xs_cut" -rd xs_out=run_dir/$tc.gds "$xs_input" -r $bin

if $klayout -b -rd a=au/$tc.gds -rd b=run_dir/$tc.gds -rd tol=10 -r run_xor.rb; then
echo "No differences found."
Expand Down

0 comments on commit 1e67ff6

Please sign in to comment.