Files
mxpic_EDA/tests/layout-backend-static.test.js
T
2026-05-28 17:53:41 +08:00

67 lines
2.6 KiB
JavaScript

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const root = path.resolve(__dirname, '..');
const backendDir = path.join(root, 'backend');
const serverPy = fs.readFileSync(path.join(backendDir, 'server.py'), 'utf8');
assert(
fs.existsSync(path.join(backendDir, 'layout_preview.py')),
'backend/layout_preview.py should generate SVG previews from saved layout YAML'
);
assert(
fs.existsSync(path.join(backendDir, 'pdk_registry.py')),
'backend/pdk_registry.py should resolve public PDK YAML/GDS assets'
);
assert(
fs.existsSync(path.join(backendDir, 'gds_builder.py')),
'backend/gds_builder.py should build hierarchical GDS from saved project YAML'
);
assert(
serverPy.includes('create_layout_svg_from_gds'),
'save-layout route should create a GDS-derived layout SVG preview'
);
assert(
serverPy.includes('svg_url'),
'save-layout response should include an svg_url for the new layout tab'
);
assert(
serverPy.includes("@app.route('/api/projects/<project_name>/cells/<cell_name>/layout.svg')"),
'server should expose a route for saved cell SVG previews'
);
assert(
serverPy.includes("@app.route('/api/build-gds'"),
'server should expose a Build GDS API route'
);
assert(
serverPy.includes("@app.route('/api/technologies/<foundry>/<technology>/manifest'"),
'server should expose a technology manifest API route'
);
assert(
fs.existsSync(path.join(backendDir, 'technology_manifest.py')),
'backend/technology_manifest.py should read generated technology manifests'
);
const techManifestPath = path.join(root, 'mxpic', 'PDKs', 'Silterra', 'EMO1_2ML_CU_Al_RDL', 'technology.yml');
assert(
fs.existsSync(techManifestPath),
'Silterra technology.yml should be generated into the EDA PDK folder'
);
const techManifest = fs.readFileSync(techManifestPath, 'utf8');
for (const xsection of ['strip', 'rib_low', 'metal_1', 'metal_2']) {
assert(techManifest.includes(`${xsection}:`), `technology.yml should include ${xsection}`);
}
assert(techManifest.includes('family: optical'), 'technology.yml should classify optical xsections');
assert(techManifest.includes('family: electrical'), 'technology.yml should classify electrical xsections');
const layoutPreviewPy = fs.readFileSync(path.join(backendDir, 'layout_preview.py'), 'utf8');
assert(
layoutPreviewPy.includes('read_gds') || layoutPreviewPy.includes('load_gds'),
'layout_preview.py should load public _BB.gds geometry, not draw only schematic boxes'
);
assert(
layoutPreviewPy.includes('_BB.gds') || layoutPreviewPy.includes('gds_path'),
'layout_preview.py should resolve public GDS assets for placed components'
);