コード例 #1
0
func TestLoadLotsOfHardware(t *testing.T) {
	context := make(map[string]interface{})

	context[constants.CTX_HARDWARE_FOLDERS] = []string{"downloaded_board_manager_stuff", "downloaded_hardware", filepath.Join("..", "hardware"), "hardware", "user_hardware"}

	loader := builder.HardwareLoader{}
	err := loader.Run(context)
	NoError(t, err)

	packages := context[constants.CTX_HARDWARE].(map[string]*types.Package)

	if runtime.GOOS == "windows" {
		//a package is a symlink, and windows does not support them
		require.Equal(t, 4, len(packages))
	} else {
		require.Equal(t, 5, len(packages))
	}

	require.NotNil(t, packages["arduino"])
	require.NotNil(t, packages["my_avr_platform"])

	require.Equal(t, 3, len(packages["arduino"].Platforms))
	require.Equal(t, 20, len(packages["arduino"].Platforms["avr"].Boards))
	require.Equal(t, 2, len(packages["arduino"].Platforms["sam"].Boards))
	require.Equal(t, 2, len(packages["arduino"].Platforms["samd"].Boards))

	require.Equal(t, 1, len(packages["my_avr_platform"].Platforms))
	require.Equal(t, 2, len(packages["my_avr_platform"].Platforms["avr"].Boards))

	if runtime.GOOS != "windows" {
		require.Equal(t, 1, len(packages["my_symlinked_avr_platform"].Platforms))
		require.Equal(t, 2, len(packages["my_symlinked_avr_platform"].Platforms["avr"].Boards))
	}
}
コード例 #2
0
func TestLoadHardware(t *testing.T) {
	context := make(map[string]interface{})
	context[constants.CTX_HARDWARE_FOLDERS] = []string{"downloaded_hardware", filepath.Join("..", "hardware"), "hardware"}

	loader := builder.HardwareLoader{}
	err := loader.Run(context)
	NoError(t, err)

	packages := context[constants.CTX_HARDWARE].(map[string]*types.Package)
	require.Equal(t, 1, len(packages))
	require.NotNil(t, packages["arduino"])
	require.Equal(t, 2, len(packages["arduino"].Platforms))

	require.Equal(t, "uno", packages["arduino"].Platforms["avr"].Boards["uno"].BoardId)
	require.Equal(t, "uno", packages["arduino"].Platforms["avr"].Boards["uno"].Properties[constants.ID])

	require.Equal(t, "yun", packages["arduino"].Platforms["avr"].Boards["yun"].BoardId)
	require.Equal(t, "true", packages["arduino"].Platforms["avr"].Boards["yun"].Properties["upload.wait_for_upload_port"])

	require.Equal(t, "{build.usb_flags}", packages["arduino"].Platforms["avr"].Boards["robotMotor"].Properties["build.extra_flags"])

	require.Equal(t, "arduino_due_x", packages["arduino"].Platforms["sam"].Boards["arduino_due_x"].BoardId)

	avrPlatform := packages["arduino"].Platforms["avr"]
	require.Equal(t, "Arduino AVR Boards", avrPlatform.Properties[constants.PLATFORM_NAME])
	require.Equal(t, "-v", avrPlatform.Properties["tools.avrdude.bootloader.params.verbose"])
	require.Equal(t, "/my/personal/avrdude", avrPlatform.Properties["tools.avrdude.cmd.path"])

	require.Equal(t, "AVRISP mkII", avrPlatform.Programmers["avrispmkii"][constants.PROGRAMMER_NAME])

	require.Equal(t, "{path}/ctags", avrPlatform.Properties["tools.ctags.cmd.path"])
}
コード例 #3
0
func TestLoadHardwareWithBoardManagerFolderStructure(t *testing.T) {
	context := make(map[string]interface{})
	context[constants.CTX_HARDWARE_FOLDERS] = []string{"downloaded_board_manager_stuff"}

	loader := builder.HardwareLoader{}
	err := loader.Run(context)
	NoError(t, err)

	packages := context[constants.CTX_HARDWARE].(map[string]*types.Package)
	require.Equal(t, 3, len(packages))
	require.NotNil(t, packages["arduino"])
	require.Equal(t, 1, len(packages["arduino"].Platforms))
	require.NotNil(t, packages["RedBearLab"])
	require.Equal(t, 1, len(packages["RedBearLab"].Platforms))
	require.NotNil(t, packages["RFduino"])
	require.Equal(t, 0, len(packages["RFduino"].Platforms))

	samdPlatform := packages["arduino"].Platforms["samd"]
	require.Equal(t, 2, len(samdPlatform.Boards))

	require.Equal(t, "arduino_zero_edbg", samdPlatform.Boards["arduino_zero_edbg"].BoardId)
	require.Equal(t, "arduino_zero_edbg", samdPlatform.Boards["arduino_zero_edbg"].Properties[constants.ID])

	require.Equal(t, "arduino_zero", samdPlatform.Boards["arduino_zero_native"].Properties["build.variant"])
	require.Equal(t, "-D__SAMD21G18A__ {build.usb_flags}", samdPlatform.Boards["arduino_zero_native"].Properties["build.extra_flags"])

	require.Equal(t, "Arduino SAMD (32-bits ARM Cortex-M0+) Boards", samdPlatform.Properties[constants.PLATFORM_NAME])
	require.Equal(t, "-d3", samdPlatform.Properties["tools.openocd.erase.params.verbose"])

	require.Equal(t, 3, len(samdPlatform.Programmers))

	require.Equal(t, "Atmel EDBG", samdPlatform.Programmers["edbg"][constants.PROGRAMMER_NAME])
	require.Equal(t, "openocd", samdPlatform.Programmers["edbg"]["program.tool"])

	avrRedBearPlatform := packages["RedBearLab"].Platforms["avr"]
	require.Equal(t, 3, len(avrRedBearPlatform.Boards))

	require.Equal(t, "blend", avrRedBearPlatform.Boards["blend"].BoardId)
	require.Equal(t, "blend", avrRedBearPlatform.Boards["blend"].Properties[constants.ID])
	require.Equal(t, "arduino:arduino", avrRedBearPlatform.Boards["blend"].Properties[constants.BUILD_PROPERTIES_BUILD_CORE])

}