@@ -4,14 +4,15 @@ import {createRequire} from "module";
44import path from "path" ;
55import { getConsoleLogPrefix } from "../../utils/getConsoleLogPrefix.js" ;
66import { runningInElectron } from "../../utils/runtime.js" ;
7+ import { BuildGpu } from "../types.js" ;
78import type { BindingModule } from "../AddonTypes.js" ;
89
910const require = createRequire ( import . meta. url ) ;
1011const __filename = fileURLToPath ( import . meta. url ) ;
1112const detectedFileName = path . basename ( __filename ) ;
1213const expectedFileName = "testBindingBinary" ;
1314
14- export async function testBindingBinary ( bindingBinaryPath : string , testTimeout : number = 1000 * 60 * 5 ) : Promise < boolean > {
15+ export async function testBindingBinary ( bindingBinaryPath : string , gpu : BuildGpu , testTimeout : number = 1000 * 60 * 5 ) : Promise < boolean > {
1516 if ( ! detectedFileName . startsWith ( expectedFileName ) ) {
1617 console . warn (
1718 getConsoleLogPrefix ( ) +
@@ -163,10 +164,14 @@ export async function testBindingBinary(bindingBinaryPath: string, testTimeout:
163164 onMessage ( message : ChildToParentMessage ) {
164165 if ( message . type === "ready" ) {
165166 forkSucceeded = true ;
166- subProcess ! . sendMessage ( { type : "start" , bindingBinaryPath} satisfies ParentToChildMessage ) ;
167+ subProcess ! . sendMessage ( {
168+ type : "start" ,
169+ bindingBinaryPath,
170+ gpu
171+ } ) ;
167172 } else if ( message . type === "done" ) {
168173 testPassed = true ;
169- subProcess ! . sendMessage ( { type : "exit" } satisfies ParentToChildMessage ) ;
174+ subProcess ! . sendMessage ( { type : "exit" } ) ;
170175 }
171176 } ,
172177 onExit ( code : number ) {
@@ -194,6 +199,12 @@ if (process.env.TEST_BINDING_CP === "true" && (process.parentPort != null || pro
194199 await binding . init ( ) ;
195200 binding . getGpuVramInfo ( ) ;
196201 binding . getGpuDeviceInfo ( ) ;
202+
203+ const gpuType = binding . getGpuType ( ) ;
204+ void ( gpuType as BuildGpu satisfies typeof gpuType ) ;
205+ if ( gpuType !== message . gpu )
206+ throw new Error ( `GPU type mismatch. Expected: ${ message . gpu } , got: ${ gpuType } ` ) ;
207+
197208 sendMessage ( { type : "done" } ) ;
198209 } catch ( err ) {
199210 console . error ( err ) ;
@@ -214,7 +225,8 @@ if (process.env.TEST_BINDING_CP === "true" && (process.parentPort != null || pro
214225
215226type ParentToChildMessage = {
216227 type : "start" ,
217- bindingBinaryPath : string
228+ bindingBinaryPath : string ,
229+ gpu : BuildGpu
218230} | {
219231 type : "exit"
220232} ;
0 commit comments