2019-09-13 23:46:12 +02:00
|
|
|
# encoding: UTF-8
|
|
|
|
|
|
|
|
|
|
# KLayout Layout Viewer
|
2025-01-04 19:28:56 +01:00
|
|
|
# Copyright (C) 2006-2025 Matthias Koefferlein
|
2019-09-13 23:46:12 +02:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program 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 for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
2020-05-24 00:59:43 +02:00
|
|
|
ruby_dir = File.join(File::dirname($0), "..", "ruby")
|
|
|
|
|
if !$:.member?(ruby_dir)
|
|
|
|
|
$:.push(ruby_dir)
|
2019-09-13 23:46:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
load("test_prologue.rb")
|
|
|
|
|
|
|
|
|
|
# Tests for the buddy executables
|
|
|
|
|
#
|
|
|
|
|
# This tests actually runs inside a KLayout/unit_tests instance but
|
|
|
|
|
# only for providing the test automation.
|
|
|
|
|
|
|
|
|
|
class Buddies_TestClass < TestBase
|
|
|
|
|
|
|
|
|
|
def buddy_bin(name)
|
2022-05-29 10:11:16 +02:00
|
|
|
file = File.join($ut_inst_path, name)
|
2019-09-13 23:46:12 +02:00
|
|
|
return file
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_basic
|
|
|
|
|
|
|
|
|
|
# Basic - buddies can be called
|
2019-11-30 20:54:15 +01:00
|
|
|
%w(strm2cif strm2dxf strm2gds strm2gdstxt strm2oas strm2mag strm2txt strmclip strmcmp strmrun strmxor).each do |bin|
|
2019-09-13 23:46:12 +02:00
|
|
|
version = bin + " " + `#{self.buddy_bin(bin)} --version`
|
|
|
|
|
assert_equal(version =~ /^#{bin} \d+\./, 0)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_converters
|
|
|
|
|
|
2019-09-17 23:10:41 +02:00
|
|
|
signatures = {
|
|
|
|
|
"strm2cif" => 0x28434946,
|
|
|
|
|
"strm2dxf" => 0x300a5345,
|
|
|
|
|
"strm2gds" => 0x00060002,
|
|
|
|
|
"strm2gdstxt" => 0x48454144,
|
|
|
|
|
"strm2oas" => 0x2553454d,
|
|
|
|
|
"strm2txt" => 0x62656769,
|
2019-11-30 20:59:47 +01:00
|
|
|
"strm2mag" => 0x6d616769,
|
2019-09-17 23:10:41 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-03 00:09:26 +01:00
|
|
|
# Windows CRLF -> LF translation
|
|
|
|
|
signature_equiv = {
|
|
|
|
|
0x300d0a53 => 0x300a5345
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-30 20:54:15 +01:00
|
|
|
%w(strm2cif strm2dxf strm2gds strm2gdstxt strm2oas strm2txt strm2mag).each do |bin|
|
2019-09-13 23:46:12 +02:00
|
|
|
|
|
|
|
|
puts "Testing #{bin} ..."
|
|
|
|
|
|
2019-11-30 20:59:47 +01:00
|
|
|
if bin == "strm2mag"
|
|
|
|
|
out_file = File.join($ut_testtmp, "TOP1.mag")
|
|
|
|
|
else
|
|
|
|
|
out_file = File.join($ut_testtmp, "out_" + bin)
|
|
|
|
|
end
|
2023-05-19 23:47:59 +02:00
|
|
|
if File.exist?(out_file)
|
2019-09-13 23:46:12 +02:00
|
|
|
File.unlink(out_file)
|
|
|
|
|
end
|
2023-05-19 23:47:59 +02:00
|
|
|
assert_equal(File.exist?(out_file), false)
|
2019-09-13 23:46:12 +02:00
|
|
|
|
|
|
|
|
in_file = File.join(File.dirname(__FILE__), "test1.gds")
|
|
|
|
|
|
|
|
|
|
log = bin + "\n" + `#{self.buddy_bin(bin)} #{in_file} #{out_file} 2>&1`
|
2023-05-19 23:47:59 +02:00
|
|
|
assert_equal(File.exist?(out_file), true)
|
2019-09-13 23:46:12 +02:00
|
|
|
assert_equal(log, bin + "\n")
|
|
|
|
|
|
2019-11-03 00:09:26 +01:00
|
|
|
File.open(out_file, "rb") do |file|
|
2019-09-17 23:10:41 +02:00
|
|
|
sig = file.read(4).unpack('N').first
|
2019-11-03 00:09:26 +01:00
|
|
|
sig = signature_equiv[sig] || sig
|
2019-09-17 23:10:41 +02:00
|
|
|
assert_equal(sig, signatures[bin])
|
|
|
|
|
end
|
|
|
|
|
|
2019-09-13 23:46:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_strmxor
|
|
|
|
|
|
|
|
|
|
out_file = File.join($ut_testtmp, "out")
|
2023-05-19 23:47:59 +02:00
|
|
|
if File.exist?(out_file)
|
2019-09-13 23:46:12 +02:00
|
|
|
File.unlink(out_file)
|
|
|
|
|
end
|
2023-05-19 23:47:59 +02:00
|
|
|
assert_equal(File.exist?(out_file), false)
|
2019-09-13 23:46:12 +02:00
|
|
|
|
|
|
|
|
in_file1 = File.join(File.dirname(__FILE__), "test1.gds")
|
|
|
|
|
in_file2 = File.join(File.dirname(__FILE__), "test2.gds")
|
|
|
|
|
|
|
|
|
|
log = "strmxor\n" + `#{self.buddy_bin("strmxor")} #{in_file1} #{in_file2} #{out_file} 2>&1`
|
2023-05-19 23:47:59 +02:00
|
|
|
assert_equal(File.exist?(out_file), true)
|
2019-09-13 23:46:12 +02:00
|
|
|
assert_equal(log, <<"END")
|
|
|
|
|
strmxor
|
|
|
|
|
Warning: Layer 1/0 is not present in second layout, but in first
|
|
|
|
|
Warning: Layer 2/0 is not present in first layout, but in second
|
|
|
|
|
Result summary (layers without differences are not shown):
|
|
|
|
|
|
|
|
|
|
Layer Output Differences (shape count)
|
2025-04-08 19:38:56 +02:00
|
|
|
----------------------------------------------------------------
|
2019-09-13 23:46:12 +02:00
|
|
|
1/0 - (no such layer in second layout)
|
|
|
|
|
2/0 - (no such layer in first layout)
|
|
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_strmcmp
|
|
|
|
|
|
|
|
|
|
in_file1 = File.join(File.dirname(__FILE__), "test1.gds")
|
|
|
|
|
in_file2 = File.join(File.dirname(__FILE__), "test2.gds")
|
|
|
|
|
|
|
|
|
|
log = "strmcmp\n" + `#{self.buddy_bin("strmcmp")} #{in_file1} #{in_file2} 2>&1`
|
|
|
|
|
assert_equal(log, <<"END")
|
|
|
|
|
strmcmp
|
|
|
|
|
ERROR: Layer 1/0 is not present in layout b, but in a
|
|
|
|
|
ERROR: Layer 2/0 is not present in layout a, but in b
|
|
|
|
|
ERROR: Cell TOP1 is not present in layout b, but in a
|
|
|
|
|
ERROR: Cell TOP2 is not present in layout a, but in b
|
|
|
|
|
ERROR: Layouts differ
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_strmclip
|
|
|
|
|
|
|
|
|
|
out_file = File.join($ut_testtmp, "out")
|
2023-05-19 23:47:59 +02:00
|
|
|
if File.exist?(out_file)
|
2019-09-13 23:46:12 +02:00
|
|
|
File.unlink(out_file)
|
|
|
|
|
end
|
2023-05-19 23:47:59 +02:00
|
|
|
assert_equal(File.exist?(out_file), false)
|
2019-09-13 23:46:12 +02:00
|
|
|
|
|
|
|
|
in_file = File.join(File.dirname(__FILE__), "test1.gds")
|
|
|
|
|
|
|
|
|
|
log = "strmclip\n" + `#{self.buddy_bin("strmclip")} #{in_file} #{out_file} 2>&1`
|
2023-05-19 23:47:59 +02:00
|
|
|
assert_equal(File.exist?(out_file), true)
|
2019-09-13 23:46:12 +02:00
|
|
|
assert_equal(log, "strmclip\n")
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_strmrun
|
|
|
|
|
|
|
|
|
|
in_file = File.join(File.dirname(__FILE__), "test2.rb")
|
|
|
|
|
|
|
|
|
|
log = "strmrun\n" + `#{self.buddy_bin("strmrun")} #{in_file} 2>&1`
|
|
|
|
|
assert_equal(log, "strmrun\ntest2\n")
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
load("test_epilogue.rb")
|